Referencing Control not on form

  • Thread starter Thread starter Eddy
  • Start date Start date
E

Eddy

How do I reference a control (textbox) that is in the query underlying the
form but not placed on the form itself. I am writing code behind the form
and want to place a value in the field. Do I have to place the field on
the form and just make it not visible?

Thanks.
 
In Access 2000 or above you can refer to any field using the Fields
collection of the Recordset:

For example:

MsgBox Me.Recordset.Fields("Orderid")

This will also work unless there is a control named Orderid which is unbound
or bound to something else (granted that this is probably a bad idea :-)).
In which case it will give you the value of the control instead:

MsgBox Me!Orderid

When possible, I prefer the first synatax since it is clear to me or anyone
else that I am going for the value from the recordset, not the control (if
one exists).
 
I think I deleted a line from my original post - it should have said that in
all versions including Access97 you can use

Me!orderid

This works unless there is a control named Orderid which is unbound or bound
to something else (granted that this is probably a bad idea). In which case
it will give you the value of the control instead:

Sorry for the confusing wording :-)
 
Back
Top