Discussion Locked

DLookup command in Access

0 helpful
7 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

I am trying to use a DLookUp command in the control source of an Access 2000 formfield. In my database:

Group=FormField trying to get from the Dlookup
Emp_Names=table that is made up of the fields "Name" and "Group"
Name=field in the Emp_Names table
QCDataEntryForm=The name of the form
Processor=FormField associated with the Tablefield "Name"

My Dlookup command entered in the control source for the "Group" field of the form:

=DLookUp("[Group]","Emp_Names","[Name]=" & [Forms]![QCDataEntryForm]![Processor])

So when the user enters a "processor" on the QCDataEntryForm, I would like the "Group" to automatically fill in with the associated value from the Emp_Names table. The value that is displayed when I run the form is [#error]. I am not sure what to change to get the correct data. Please help.

7 replies

by dakota99

Thanks for your help. I changed the criteria to:
=DLookUp("[Group]","Emp_Names","[Name]=" & Me.Processor)

The message that is now displayed in the dlookup field id "#Name?"

by john_wills

=DLookUp("[PHYS_ADDR1]","dbo_provsite","[PROV_ID] = " & [Prov_ID])
The above works in one of my reports. Perhaps the "me" in what I told you is inappropriate, but I don't know why. Prov_ID appears in the table for the report as shown by clicking onthe table icon next to the hammer-and-spanner. Does your Processor appear there?

by bob sellman

It looks like you forgot to surround the string value (for Name) with single quotes. So the last part of the DLookUp function would look like this (including the closing parenthesis):

","[Name]='" & [Forms]![QCDataEntryForm]![Processor] & "'")

by dakota99

I made the changes you suggested...It worked, it worked, it worked!!!!!!! I have been working on this off and on for a number of weeks now. I just couldn't get the syntax quite right.
Thanks for all your help!!!!!!!!!!!!!

This discussion is closed to new replies.