Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Storing a table field value directly to a public variable 2

Status
Not open for further replies.

rew2009

Technical User
Apr 21, 2009
114
US
I have table named “APTS” and a field named ‘Owner_Lname1_Corp’. I have a form where the record source is the ‘APTS’ table. I also have a public variable named ‘owner’

I want to store the value from ‘Owner_Lname1_Corp’ in the public variable ‘owner’.

I know that I can bind a text box (such as ‘text82’) to the field ‘Owner_Lname1_Corp’ and store the value in the ‘owner’ variable with a form:

Owner=Me.text82.value , where ‘text82’ is bound to ‘Owner_Lname1_Corp’.

However, I want to store the current record value for ‘Owner_Lname1_Corp’ directly from the table without going through the ‘Me.text82.value’ method.

I tried the following code in the event method of a command button :

'owner=[APTS].Owner_Lname1_Corp '

But get the error ‘2465’

‘ APT DATABASES can’t find the field ‘|’ referred to in your expression.’

What am I doing wrong?

 
When you bind a recordset to a form then you can refer to the fields on the form as properties of the form, even if the fields are not bound to controls on the form.

owner = me!Owner_Lname1_Corp

you can not refer directly to the table. If you want to pull values from the you will need to use a dlookup or refer to a recordset of the table.
 
How are ya rew2009 . . .

You say:
rew2009 said:
[blue]I want to store the current record value for 'Owner_Lname1_Corp' directly from the table without going through the 'Me.text82.value' method.[/blue]
TheAceMan1 said:
[blue]When a field is bound, the [blue]Control Source[/blue] is simply prescribed the [blue]name of the field[/blue]. You can't get any more direct than this![/blue]
To put this value in a variable or alternate textbox, there's no other way except to refer to the form and control:

[blue]Owner = Me[Owner_Lname1_Corp][/blue]

[blue]Your Thoughts? . . .[/blue]

See Ya! . . . . . .

Be sure to see thread181-473997 [blue]Worthy Reading![/blue] [thumbsup2]
Also faq181-2886 [blue]Worthy Reading![/blue] [thumbsup2]
 
Thanks MajP and the Aceman1, that was the code that I was looking for. I have another question about storing OLE Objects in Public Variable but I will start a new thread.

Thanks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top