473,399 Members | 3,888 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,399 software developers and data experts.

Refer to itself

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
4 4248
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
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
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
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

7
by: Ivo | last post by:
How do I make the magic 'this' variable refer to an object of my choice, in a string of code which is to be eval'ed? Say, I have an object, an array with four elements: var myobject = ; and a...
5
by: Joe Fallon | last post by:
I have a user control which can appear on many pages. The control needs to know which page it is on so it can render itself correctly. What is the best way for the control to find out what page is...
2
by: shisncreen | last post by:
Is there any way to refer to a dataset using a variable. This is what I would like to do . . . FunctionPopulateDropDownList(DataSetName as string) . . . myDataAdapter.Fill(DataSetName,...
2
by: ProRodman | last post by:
Dear all, I know that "me" can be used to refer current active form. How can I refer an object (e.g. a button) within it's own event code without using the object name (something just like...
8
by: Sullivan WxPyQtKinter | last post by:
When debugging using 'print' statement, I usually want to print some important values together with the function name as the context of the values printed out. So my hope is that I could get the...
0
by: Larry Lard | last post by:
This came out of a thread explaining to "BK" about error BC42025 ("Access of shared member through an instance; qualifying expression will not be evaluated"); Frans Clasener then came up with...
1
by: Kai Zhu | last post by:
I've write a script like this. <script> function A() { this.onMouseDown = function(event) { ..... } } var objA = new A(); htmlelement.onmousedown = a.onmousedown; </script>
8
by: Andy B | last post by:
Is there a way to refer to things in Session object without calling Session itself?
3
by: yosibeck | last post by:
sorry folks, I'm sure this is a newbie question. On my website I have one DIV (id="menu") with position:fixed that serves as a fixed menu bar. Then comes the second DIV (id="content") that holds...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.