Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

DLookUp Function Question 2

Status
Not open for further replies.

starflt1701

Technical User
Jun 4, 2001
25
US
Can anyone help me with the DLookUp function? I want to display, in a form, a value in a field, from a foreign table or query, based on the entered value of another field (control) on the form. My Access manual, and the help function in Access do not agree on the proper formatting of the expression. However, I have tried both, and neither work. If there is a better way other than DLookUp to accomplish my objective, can you please recommend in detail?

Thanks,
 
The syntax for DLookUp() is:

DLookUp("[FieldToLookUp]", "TableOrQueryName", "[CriteriaField] = " & Forms!FormName!Criteria)

You can also try simply adding the table or query that has the value you wish to lookup to the form's underlying recordset and link it via the lookup field. The only problem with this is you may end up with an non-updatable recordset.
 
If the criteria field is a string then you will need to add apostropes...

DLookUp "[FieldToLookUp]", "TableOrQueryName", "CriteriaField]" = '" & Forms!FormName!Criteria & "'")
ljprodev@yahoo.com
ProDev
MS Access Applications
 
If the criteria field is a string then you will need to add apostropes...

DLookUp "[FieldToLookUp]", "TableOrQueryName", "CriteriaField] = '" & Forms!FormName!Criteria & "'")

Sorry I had one extra quotation mark in the expression. ljprodev@yahoo.com
ProDev
MS Access Applications
 
Ok. Thanks for the help with the syntax. DLookUp is now working great. However, all I can do at this point is look up the related field. I want to be able to save the looked up information to a new table via the form. I have 2 primary fields: Job No. and Part Code. I want to look up the part code associated with a job number I key into my form, and save both fields to another table (along with other keyed information). How do I do that?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top