Object-variable of a subroutine

  • Thread starter Thread starter Reiner Harmgardt
  • Start date Start date
R

Reiner Harmgardt

Hi NG

(ACCESS 97)

In my form i have several Textboxes like:
1_NEW,
2_NEW
3_NEW
etc.

If i jump into the ENTER-Routines of thes objects
i'm in f.e. Private Sub ctl1_New_Enter()

Which variable gives me back the Name of this Subroutine?

tried different stuff on the me.??? but nothing worked.

I need to figure out the number of the textbox, in which i am,
to set up according actions, depending on that number.

Thanks for helping

Regards

Reiner
 
Reiner,

<<Which variable gives me back the Name of this Subroutine?>>
There is no way to programmatically know which procedure is running at any
given time.

If you need to know, you'll have to code for it yourself.

Regards,
Graham R Seach
Microsoft Access MVP
Sydney, Australia
 
In my form i have several Textboxes like:
1_NEW,
2_NEW
3_NEW
etc.
You have different possabilities:
On Form_After Update you can check out, what´s in your textboxes with
str = Me.1_New 'for example
the other way is to check out befor updating the form
On Form_Before Update
If IsNull(Me.1_New) Or Me.I_New = "" then
MsgBox = "Textbox1 nothing inside"
Else
MsgBox = "Textbox1: " & Me.1_New
End if
.....
Describe, what do you want to do exactly - hope I understand it correctly.
You can also make an action after every textbox like:
On 1_New AfterUpdate
If IsNull(Me.1_New) Or Me.1_New = "" then
MsgBox "nothing here"
Else
MsgBox "somebody write this: " & Me.1_New
End if
End Sub

Kai Apel (Berlin)
 
Hi Kai

here a litte more in detail what i want to do:

i have 20 Textboxes:
1 - 10 called 1 NEW, 2 NEW, 3 NEW ..... 10 NEW
1- 10 called 1 REC, 2 REC, 3 REC .........10 REC

under me. they can be seen as me.ctl1_NEW, me.ctl2_NEW etc.

anytime i enter on of these textboxes the concerned ENTER-Routing is
activated:

Private Sub Ctl1_NEW_Enter()
Call Ausgang_Enter("Ctl1_NEW")
End Sub

Private Sub Ctl2_NEW_Enter()
Call Ausgang_Enter("Ctl2_NEW")
End Sub

Private Sub Ctl3_NEW_Enter()
Call Ausgang_Enter("Ctl3_NEW")
End Sub

....

Private Sub Ctl10_NEW_Enter()
Call Ausgang_Enter("Ctl10_NEW")
End Sub

The same for the _REC-objects.

Problem 1:
I thought, that there would be a variable for the active Subroutine
or even the active Object, if it is the active Object, when i'm entering the
Textbox.

out of this variable i wanted to cut out the Nr(1 to 10) and if it's NEW or
REC.

In the following subroutines(Ausgang_Enter) i check, whether the texbox has
to be locked or not.

Problem 2:
there i am also missing the possibility to say me(xControl).locked = true
(xControl ="ctl1_NEW)

Problem 1 i have solved in writing the explicit object-name into the
variable of the subroutine.

Problem 2 i thought i had already solved, but it didn't work.
So maybe in the end i have to do it the same way as concerning problem 1.
But i mean that i have already seen something like that somewhere in older
posts.

So hopefully this explains a litte bit better what i'm trying to achieve.

Thanks for supporting me

Have a nice day.

Regards

Reiner
 
Reiner Harmgardt said:
Hi Kai

here a litte more in detail what i want to do:

i have 20 Textboxes:
1 - 10 called 1 NEW, 2 NEW, 3 NEW ..... 10 NEW
1- 10 called 1 REC, 2 REC, 3 REC .........10 REC

under me. they can be seen as me.ctl1_NEW, me.ctl2_NEW etc.

anytime i enter on of these textboxes the concerned ENTER-Routing is
activated:

Private Sub Ctl1_NEW_Enter()
Call Ausgang_Enter("Ctl1_NEW")
End Sub

Private Sub Ctl2_NEW_Enter()
Call Ausgang_Enter("Ctl2_NEW")
End Sub

Private Sub Ctl3_NEW_Enter()
Call Ausgang_Enter("Ctl3_NEW")
End Sub

...

Private Sub Ctl10_NEW_Enter()
Call Ausgang_Enter("Ctl10_NEW")
End Sub

The same for the _REC-objects.

Problem 1:
I thought, that there would be a variable for the active Subroutine
or even the active Object, if it is the active Object, when i'm
entering the Textbox.

out of this variable i wanted to cut out the Nr(1 to 10) and if it's
NEW or REC.

In the following subroutines(Ausgang_Enter) i check, whether the
texbox has to be locked or not.

Problem 2:
there i am also missing the possibility to say me(xControl).locked =
true (xControl ="ctl1_NEW)

Problem 1 i have solved in writing the explicit object-name into the
variable of the subroutine.

Problem 2 i thought i had already solved, but it didn't work.
So maybe in the end i have to do it the same way as concerning
problem 1. But i mean that i have already seen something like that
somewhere in older posts.

So hopefully this explains a litte bit better what i'm trying to
achieve.

Thanks for supporting me

Have a nice day.

Regards

Reiner

As Graham said, there's no built-in way to know what procedure is
currently executing, but there *is* a way to know what control currently
has the focus. The form's ActiveControl property returns a reference to
the Control object that currently has the focus. So in a common
function you could use

Me.ActiveControl.Name

to get the name of the active control, or set properties if the control
itself using statements like this:

Me.ActiveControl.Locked = True
 
hello Dirk

that's just what i was looking for.
works perfect.

thanks a lot and have a nice day.

regards

Reiner
 
Back
Top