|
 |
access thread: textbox name property
Message #1 by "Howard Stone" <ququmber@h...> on Wed, 12 Dec 2001 17:37:41
|
|
First, I want to thank all who answered my previous questions. I
appreciate it sincerely. As a consequence of my appreciation, I have made
a commitment to myself and to this forum that once I learn enough to be
able to assist others, I will devote time to help them in the same way I
am being presently helped.
I created a table and have 2 columns called Electricty(Exc Pool) and
Electricty(Inc Pool ). I bulit a form and observed that its name
properties are Electricty(Exc Pool) and Electricty(Inc Pool ). I also
notice that when I create a procedure the underscore is added so I used
that as the name property of my text box.
I want to create a procedure give the end use a message as follows:
Private Sub Electricty_Exc_Pool__BeforeUpdate(Cancel As Integer)
Dim msg As Integer
msg = MsgBox("If the account number of electricty bill is 32785, this
entry should be entered in the Electricty(Inc Pool ) account", vbOKCancel)
If msg = vbCancel Then
Electricty_Exc_Pool = vbNullString ' to clear text box of the
entry
Electricty_Inc_Pool.SetFocus ' to set focus to this
text box to accept entry
End If
End Sub
I am getting an error message saying that Electricty_Exc_Pool and
Electricty_Inc_Pool in not defined
The problem I realise is the labelling of the text box name property.
Question
How should I have labelled the text box so I can use its name property
directly ?.
In Visual Basic the name you give the text box is what one uses as its
name property. It seems that it is different in VBA
and this is the confusion I am having.
Thanks for the response.
Howard Stone
Message #2 by "patrick slesicki" <patrick_slesicki@d...> on Wed, 12 Dec 2001 23:11:53
|
|
If the code is in a form or report module, try using the Me keyword. E.g.
try Me.Exc_Pool
> First, I want to thank all who answered my previous questions. I
> appreciate it sincerely. As a consequence of my appreciation, I have
made
> a commitment to myself and to this forum that once I learn enough to be
> able to assist others, I will devote time to help them in the same way I
> am being presently helped.
>
> I created a table and have 2 columns called Electricty(Exc Pool) and
> Electricty(Inc Pool ). I bulit a form and observed that its name
> properties are Electricty(Exc Pool) and Electricty(Inc Pool ). I also
> notice that when I create a procedure the underscore is added so I used
> that as the name property of my text box.
>
> I want to create a procedure give the end use a message as follows:
>
> Private Sub Electricty_Exc_Pool__BeforeUpdate(Cancel As Integer)
> Dim msg As Integer
> msg = MsgBox("If the account number of electricty bill is 32785,
this
> entry should be entered in the Electricty(Inc Pool ) account",
vbOKCancel)
> If msg = vbCancel Then
> Electricty_Exc_Pool = vbNullString ' to clear text box of the
> entry
> Electricty_Inc_Pool.SetFocus ' to set focus to
this
> text box to accept entry
> End If
>
>
> End Sub
>
>
> I am getting an error message saying that Electricty_Exc_Pool and
> Electricty_Inc_Pool in not defined
>
> The problem I realise is the labelling of the text box name property.
>
> Question
>
> How should I have labelled the text box so I can use its name property
> directly ?.
> In Visual Basic the name you give the text box is what one uses as its
> name property. It seems that it is different in VBA
> and this is the confusion I am having.
>
> Thanks for the response.
>
>
> Howard Stone
Message #3 by brian.skelton@b... on Wed, 12 Dec 2001 23:30:59
|
|
Howard
If your control is named 'Electricty Exc Pool', you would refer to it in
VBA as follows:
Me![Electricty Exc Pool]
or Me.[Electricty Exc Pool]
Where 'Me' is a shorthand reference to the current form.
To refer to a control on another form:
Forms![Another Form Name]![Electricty Exc Pool]
or Forms![Another Form Name].[Electricty Exc Pool]
You use the [] to contain object names that have spaces or other special
characters within them. If your control was named 'ElectrictyExcPool' you
could leave them out.
Hope this helps
-Brian
> First, I want to thank all who answered my previous questions. I
> appreciate it sincerely. As a consequence of my appreciation, I have
made
> a commitment to myself and to this forum that once I learn enough to be
> able to assist others, I will devote time to help them in the same way I
> am being presently helped.
>
> I created a table and have 2 columns called Electricty(Exc Pool) and
> Electricty(Inc Pool ). I bulit a form and observed that its name
> properties are Electricty(Exc Pool) and Electricty(Inc Pool ). I also
> notice that when I create a procedure the underscore is added so I used
> that as the name property of my text box.
>
> I want to create a procedure give the end use a message as follows:
>
> Private Sub Electricty_Exc_Pool__BeforeUpdate(Cancel As Integer)
> Dim msg As Integer
> msg = MsgBox("If the account number of electricty bill is 32785,
this
> entry should be entered in the Electricty(Inc Pool ) account",
vbOKCancel)
> If msg = vbCancel Then
> Electricty_Exc_Pool = vbNullString ' to clear text box of the
> entry
> Electricty_Inc_Pool.SetFocus ' to set focus to
this
> text box to accept entry
> End If
>
>
> End Sub
>
>
> I am getting an error message saying that Electricty_Exc_Pool and
> Electricty_Inc_Pool in not defined
>
> The problem I realise is the labelling of the text box name property.
>
> Question
>
> How should I have labelled the text box so I can use its name property
> directly ?.
> In Visual Basic the name you give the text box is what one uses as its
> name property. It seems that it is different in VBA
> and this is the confusion I am having.
>
> Thanks for the response.
>
>
> Howard Stone
|
|
 |