DLookup

G

Guest

I copied this directly from MS Access Help, substituting my data, but it does
not work. I keep getting #Name.

=DLookUp("[RecvgHull]","LIDetails","[id_LI] = " & Forms!LineItem!id_LI)

My understanding of this formula is:
=DLookUp (Field Name, Table Name, ID# = Forms!Field Name!ID#)
Is my understanding of this formula correct?

How do I get this to work?
 
J

Jeff Boyce

Nanette

Check Access HELP for syntax and examples.

use Forms!FormName!FieldName

If the ID is a number, that looks reasonable. If a text value, it needs
quotes.

Access shows #Name when it cannot find a table or field name as written.
This can happen if you have re-entered text instead of copy/paste.

Regards

Jeff Boyce
Microsoft Office/Access MVP
 
F

fredg

I copied this directly from MS Access Help, substituting my data, but it does
not work. I keep getting #Name.

=DLookUp("[RecvgHull]","LIDetails","[id_LI] = " & Forms!LineItem!id_LI)

My understanding of this formula is:
=DLookUp (Field Name, Table Name, ID# = Forms!Field Name!ID#)
Is my understanding of this formula correct?

How do I get this to work?

What is the datatype of [id_LI]? Number or Text?
What is the name of the form that is calling this DLookUp?
All the above will affect the syntax needed.

I'll assume it is the control source of an unbound text control on the
form named "LIDetails".

If [id_LI] is a Number datatype, then:

=DLookUp("[RecvgHull]","LIDetails","[id_LI] = " & Me![id_LI])

If [id_LI] is a Text datatype field, then:

=DLookUp("[RecvgHull]","LIDetails","[id_LI] = '" & Me![id_LI] & "'")

Make sure the name of the control is not the same as the name of any
field in it's control source expression.
 
G

Guest

Hi Jeff,

Thanks for clearing up what the formula means. I've changed the code to:

It works!

I decided to put the form into another form as a subform. So, I changed the
code to be:
=DLookUp("[RecvgHull]","LIDetails","[id_LI] = " &
Forms!frmContracts.sfrmContractsA!id_LI)
This did not work.
Thinking that it might depend on having the sfrmContractsA open, I created a
macro to open the sfrmContractsA.
That didn't work either.

Any suggestions?

Jeff Boyce said:
Nanette

Check Access HELP for syntax and examples.

use Forms!FormName!FieldName

If the ID is a number, that looks reasonable. If a text value, it needs
quotes.

Access shows #Name when it cannot find a table or field name as written.
This can happen if you have re-entered text instead of copy/paste.

Regards

Jeff Boyce
Microsoft Office/Access MVP

Nanette said:
I copied this directly from MS Access Help, substituting my data, but it
does
not work. I keep getting #Name.

=DLookUp("[RecvgHull]","LIDetails","[id_LI] = " & Forms!LineItem!id_LI)

My understanding of this formula is:
=DLookUp (Field Name, Table Name, ID# = Forms!Field Name!ID#)
Is my understanding of this formula correct?

How do I get this to work?
 
J

Jeff Boyce

Nanette

Check Access HELP for referring to controls on subforms in expressions.

If I recally correctly, it goes something like:
Forms!FormName!NameOfSubformControlOnMainForm.Form!NameOfControlOnSubform

Regards

Jeff Boyce
Microsoft Office/Access MVP

Nanette said:
Hi Jeff,

Thanks for clearing up what the formula means. I've changed the code to:

It works!

I decided to put the form into another form as a subform. So, I changed
the
code to be:
=DLookUp("[RecvgHull]","LIDetails","[id_LI] = " &
Forms!frmContracts.sfrmContractsA!id_LI)
This did not work.
Thinking that it might depend on having the sfrmContractsA open, I created
a
macro to open the sfrmContractsA.
That didn't work either.

Any suggestions?

Jeff Boyce said:
Nanette

Check Access HELP for syntax and examples.

use Forms!FormName!FieldName

If the ID is a number, that looks reasonable. If a text value, it needs
quotes.

Access shows #Name when it cannot find a table or field name as written.
This can happen if you have re-entered text instead of copy/paste.

Regards

Jeff Boyce
Microsoft Office/Access MVP

Nanette said:
I copied this directly from MS Access Help, substituting my data, but it
does
not work. I keep getting #Name.

=DLookUp("[RecvgHull]","LIDetails","[id_LI] = " & Forms!LineItem!id_LI)

My understanding of this formula is:
=DLookUp (Field Name, Table Name, ID# = Forms!Field Name!ID#)
Is my understanding of this formula correct?

How do I get this to work?
 

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

DLookUp 10
Dlookup in table won't work 2
DLookup Issue 9
dlookup not working - 2
DLookup Syntex error it is killing me 7
dlookup using variable as criteria 1
Pulling data into a form and making it save 7
DLookup 2

Top