DLookup referenced by a control

G

Guest

In a form, I would like DLookup to return a value in a field referenced by
another control such as that:

=Dlookup("{field referenced by another control}","
","{record in
form}={record in table}")

I hope this is easy to understand and does anyone know how to solve this
issue? Thank you in advance.
 
M

Marshall Barton

Robert T. said:
In a form, I would like DLookup to return a value in a field referenced by
another control such as that:

=Dlookup("{field referenced by another control}","
","{record in
form}={record in table}")

I hope this is easy to understand and does anyone know how to solve this
issue?



The first argument to DLookup is a string containg the name
of the field you want to retrieve. So if {field referenced
by another control} means that the other control actually
contains the name of the field, you can just use:

For a numeric fieldintable, it would be:
=Dlookup(theothercontrol,"
","fieldin table=" &
fieldintable)

If fieldintable is a text field, it would be:
=Dlookup(theothercontrol,"
","fieldin table=""" &
fieldintable & """")

For a date field:
=Dlookup(theothercontrol,"
","fieldin table=" &
Format(fieldintable, "\#m\/d\/yyyy\#"))
 
G

Guest

Thank you for your response.
You have the correct idea that i'm looking for, but, unless I'm mistaken by
your repsonse, the expression(s) you gave doesn't seem to be working. All
it's doing is giving me the the string that the control contains rather than
looking for the field with the name equal to that of the string in the given
control. If it helps any, the string is a numeric value and the field(s) in
the other table are numeric.

:
The first argument to DLookup is a string containg the name
of the field you want to retrieve. So if {field referenced
by another control} means that the other control actually
contains the name of the field, you can just use:

For a numeric fieldintable, it would be:
=Dlookup(theothercontrol,"
","fieldin table=" &
fieldintable)

If fieldintable is a text field, it would be:
=Dlookup(theothercontrol,"
","fieldin table=""" &
fieldintable & """")

For a date field:
=Dlookup(theothercontrol,"
","fieldin table=" &
Format(fieldintable, "\#m\/d\/yyyy\#"))
 
G

Guest

Thanks everyone for the help, but I have found the answer to my own question,
but I will share my answer incase someone comes up with a similar question as
my own.

All that needs to be done is to nest the value of the field in [ ] such a
way that:

=DLookup("["&[{NameOfControl}&"]","
","{RrecordInForm}={RecordInTable}")
 
M

Marshall Barton

You've lost me, maybe there's a terminolgy issue? Could you
provide me with an example of the the table fields and a few
records along with some of the values that can be in the
control?
 

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

Similar Threads


Top