DLookup Needed?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Hi everyone,
I am having an issue trying to get an unbound field in form1 to display a
value from a column in table2. Table1 is the control source for form1.
Table1 is linked to Table2 by an ID field, but I would like the description
for the record from Table2 to appear in the unbound field on form1.
Next question, what event would I use to trigger this so that this field
will be updated on the initial load, and also between every record switch.
Any help is always appreciated, thanks!
-gary
 
DLookup is probably your best approach for doing this. Use the form's
Current event to run programming to use DLookup.
 
Ken Snell (MVP) said:
DLookup is probably your best approach for doing this. Use the form's
Current event to run programming to use DLookup.

What about a calculated control, instead of an unbound one, with a
controlsource expression like

=DLookup("DescriptionField", "Table2", "ID=" & [ID])

? It's not completely clear to me what Gary is after, but this might do
it.
 
Hi -

You could also base the form on a query linking the two tables; then you
could bind the description control on form1 to the field in table2.

John
 
Yes, that also will work. And it would avoid having to run code in the
form's Current event.

I wasn't thinking about that option because I'd just finished with another
thread where the person wanted to bind the textbox to a field in the form's
recordsource, and it was still "fresh in my mind" < g >.

--

Ken Snell
<MS ACCESS MVP>


Dirk Goldgar said:
Ken Snell (MVP) said:
DLookup is probably your best approach for doing this. Use the form's
Current event to run programming to use DLookup.

What about a calculated control, instead of an unbound one, with a
controlsource expression like

=DLookup("DescriptionField", "Table2", "ID=" & [ID])

? It's not completely clear to me what Gary is after, but this might do
it.

--
Dirk Goldgar, MS Access MVP
www.datagnostics.com

(please reply to the newsgroup)
 
Thanks! That did it! I did notice that there is a delay in this field
appearing, is this normal?
-gary

Dirk Goldgar said:
Ken Snell (MVP) said:
DLookup is probably your best approach for doing this. Use the form's
Current event to run programming to use DLookup.

What about a calculated control, instead of an unbound one, with a
controlsource expression like

=DLookup("DescriptionField", "Table2", "ID=" & [ID])

? It's not completely clear to me what Gary is after, but this might do
it.

--
Dirk Goldgar, MS Access MVP
www.datagnostics.com

(please reply to the newsgroup)
 
Yes, it takes a few milliseconds for the query to run via the DLookup
function.

--

Ken Snell
<MS ACCESS MVP>

Gary Dolliver said:
Thanks! That did it! I did notice that there is a delay in this field
appearing, is this normal?
-gary

Dirk Goldgar said:
Ken Snell (MVP) said:
DLookup is probably your best approach for doing this. Use the form's
Current event to run programming to use DLookup.

What about a calculated control, instead of an unbound one, with a
controlsource expression like

=DLookup("DescriptionField", "Table2", "ID=" & [ID])

? It's not completely clear to me what Gary is after, but this might do
it.

--
Dirk Goldgar, MS Access MVP
www.datagnostics.com

(please reply to the newsgroup)
 
Back
Top