By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
445,824 Members | 1,247 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 445,824 IT Pros & Developers. It's quick & easy.

Refer to itself

P: n/a
I have a bound textfield in my form. In the beforeupdate event of that field
I want to refer to that field's value. What's the easiest way to refer to
that field's value?

st = MyFieldName works but I'd rather refer in a more generic way like
st = Me (which doesn't work).

Thanks,
john


Sep 30 '07 #1
Share this Question
Share on Google+
4 Replies


P: n/a
Unfortunately, Access does not expose the name of the control the event is
for, or the name of the executing event.

If the user typed into the control, it will be:
Me.ActiveControl

That may not be the case if the event procedure is executing because you
called it like this:
Call Text0_BeforeUpdate(False)

--
Allen Browne - Microsoft MVP. Perth, Western Australia
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"john" <hg*@neckso.comwrote in message
news:b7***************************@cache120.multik abel.net...
>I have a bound textfield in my form. In the beforeupdate event of that
field I want to refer to that field's value. What's the easiest way to
refer to that field's value?

st = MyFieldName works but I'd rather refer in a more generic way like
st = Me (which doesn't work).

Thanks,
john
Sep 30 '07 #2

P: n/a
Hi, John.
I want to refer to that field's value. What's the easiest way to refer to
that field's value?
To avoid bugs, circular references, et cetera, change the name of the
control bound to the field from the field's name (which is the default when
Access creates the bound control) to something else, such as
txtInvoiceAmount, instead of InvoiceAmount. Example VBA syntax:

variableName = Me!ControlName.Value

or

variableName = Me.ControlName.Value
st = Me (which doesn't work).
In this case, Me refers to the form itself.

HTH.
Gunny

See http://www.QBuilt.com for all your database needs.
See http://www.Access.QBuilt.com for Microsoft Access tips and tutorials.
Blogs: www.DataDevilDog.BlogSpot.com, www.DatabaseTips.BlogSpot.com
http://www.Access.QBuilt.com/html/ex...ributors2.html for contact
info.
Sep 30 '07 #3

P: n/a
Hi, John.

I think I misunderstood your question. You aren't looking to hard code the
control's name. In that case, follow Allen Browne's good advice.

HTH.
Gunny

See http://www.QBuilt.com for all your database needs.
See http://www.Access.QBuilt.com for Microsoft Access tips and tutorials.
Blogs: www.DataDevilDog.BlogSpot.com, www.DatabaseTips.BlogSpot.com
http://www.Access.QBuilt.com/html/ex...ributors2.html for contact
info.
"'69 Camaro" <Fo**************************@Spameater.orgZERO_SP AMwrote in
message news:5PPLi.328$0I5.63@trnddc08...
Hi, John.
>I want to refer to that field's value. What's the easiest way to refer to
that field's value?

To avoid bugs, circular references, et cetera, change the name of the
control bound to the field from the field's name (which is the default
when Access creates the bound control) to something else, such as
txtInvoiceAmount, instead of InvoiceAmount. Example VBA syntax:

variableName = Me!ControlName.Value

or

variableName = Me.ControlName.Value
>st = Me (which doesn't work).

In this case, Me refers to the form itself.

HTH.
Gunny

See http://www.QBuilt.com for all your database needs.
See http://www.Access.QBuilt.com for Microsoft Access tips and tutorials.
Blogs: www.DataDevilDog.BlogSpot.com, www.DatabaseTips.BlogSpot.com
http://www.Access.QBuilt.com/html/ex...ributors2.html for contact
info.

Sep 30 '07 #4

P: n/a
Thanks!
John

"Allen Browne" <Al*********@SeeSig.Invalidschreef in bericht
news:46**********************@per-qv1-newsreader-01.iinet.net.au...
Unfortunately, Access does not expose the name of the control the event is
for, or the name of the executing event.

If the user typed into the control, it will be:
Me.ActiveControl

That may not be the case if the event procedure is executing because you
called it like this:
Call Text0_BeforeUpdate(False)

--
Allen Browne - Microsoft MVP. Perth, Western Australia
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

"john" <hg*@neckso.comwrote in message
news:b7***************************@cache120.multik abel.net...
>>I have a bound textfield in my form. In the beforeupdate event of that
field I want to refer to that field's value. What's the easiest way to
refer to that field's value?

st = MyFieldName works but I'd rather refer in a more generic way like
st = Me (which doesn't work).

Thanks,
john

Sep 30 '07 #5

This discussion thread is closed

Replies have been disabled for this discussion.