DLookup Question

  • Thread starter Thread starter rollover99 via AccessMonster.com
  • Start date Start date
R

rollover99 via AccessMonster.com

I have searched many different threads with no luck.

I have a text box (DeptID) that is bound to a form (MFA)

I am using the DeptID in an unbound text box that looks at the table
(Departments) to get the Department that is associated with the DeptID.

Just can't figure this out. I am using

=DLookup("[Department]", "Departments", "[DeptID] =" _ & Forms![MFA]!DeptID)

as my control source. Keep getting a syntax error. I want to lookup the
department via the DeptID in the Departments table to fill in my text box.

Any help on this would be appreciated.
 
First, the underscore should not be in the statement.
=DLookup("[Department]", "Departments", "[DeptID] =" _ & Forms![MFA]!DeptID)
Should be
=DLookup("[Department]", "Departments", "[DeptID] =" & Forms![MFA]!DeptID)

The syntax you have says that [DeptID] is a numeric field. If it is a text
field:
=DLookup("[Department]", "Departments", "[DeptID] = '" & Forms![MFA]!DeptID
& "')"

Getting the naming correct so that Access understands it in a Control Source
can be tricky. If the above does not correct it, try this:
=DLookup("[Department]", "Departments", "[DeptID] =" & DeptID)

Add the quotes as above if it is text
 
Dlookups give me issues too. I used the help you gave and figured it out.

Thanks
 
Back
Top