DLookup Needed?

G

Gary Dolliver

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
 
K

Ken Snell \(MVP\)

DLookup is probably your best approach for doing this. Use the form's
Current event to run programming to use DLookup.
 
D

Dirk Goldgar

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.
 
J

J. Goddard

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
 
K

Ken Snell \(MVP\)

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)
 
G

Gary Dolliver

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)
 
K

Ken Snell \(MVP\)

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)
 

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