Look up data from a table in a text box

  • Thread starter Jesse via AccessMonster.com
  • Start date
J

Jesse via AccessMonster.com

Hello, I have a text box on a form and I would like data to be viewed from a
table. In the properties of the text box on the control source I place
=[Date Ran]![DT_TM_RAN]. I thought this would show the data in the DT_TM_RAN
field in the text box. But when I open the form it shows
#Name?
Can someone please direct me in the right direction to fix this issue. Thanks
for your time.
 
F

fredg

Hello, I have a text box on a form and I would like data to be viewed from a
table. In the properties of the text box on the control source I place
=[Date Ran]![DT_TM_RAN]. I thought this would show the data in the DT_TM_RAN
field in the text box. But when I open the form it shows
#Name?
Can someone please direct me in the right direction to fix this issue. Thanks
for your time.

[Date Ran] is the name of the table?

=DLookUp("[DT_TM_RAN]","[Date Ran]")
will return the first value in the table.
If you wish a specific record's value returned you need to add a Where
clause to the above expression.

Assuming the form is displaying a unique record ID, and that field
([RecordID]) is a Number datatype, then something like this:

=DLookUp("[DT_TM_RAN]","[Date Ran]","[RecordID] = " & Me.[RecordID)

Look up the DLookUp function in VBA help and also
"restrict data to a subset of records"
for the correct syntax for Text or Date datatypes.
 
J

Jesse via AccessMonster.com

DLookUp is exactly what i needed. I cant beleive i didnt think of that. Thank
you for you time and advise.
Hello, I have a text box on a form and I would like data to be viewed from a
table. In the properties of the text box on the control source I place
[quoted text clipped - 3 lines]
Can someone please direct me in the right direction to fix this issue. Thanks
for your time.

[Date Ran] is the name of the table?

=DLookUp("[DT_TM_RAN]","[Date Ran]")
will return the first value in the table.
If you wish a specific record's value returned you need to add a Where
clause to the above expression.

Assuming the form is displaying a unique record ID, and that field
([RecordID]) is a Number datatype, then something like this:

=DLookUp("[DT_TM_RAN]","[Date Ran]","[RecordID] = " & Me.[RecordID)

Look up the DLookUp function in VBA help and also
"restrict data to a subset of records"
for the correct syntax for Text or Date datatypes.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top