dlookup with query issue

hudaz

Registered User.
Local time
Today, 11:36
Joined
Jan 22, 2013
Messages
28
Hi,

i'm currently trying to display a date on a form via a dlookup but i'm comming across some issues.

The query's name is PRISM_SAMPLEDATE
The field with information i want to display on my form is PLANNEDSTARTDATE
and i want it to relate to my form (Design_Detail_ProjectManagement) to the query via the JobNumber

So far i've just been getting #error.

could anyone advise ? the dlookup is below for reference and mockery :-)

=DLookUp("[PRISM_SAMPLEDATE]","[PLANNEDSTARTDATE]","[JobNumber] = " & [Forms]![Design_Detail_ProjectManagement]![JobNumber])
 
It looks like your syntax is backwards. The format for DLookup is this:

Code:
DLookup("[NameOfFieldToSearchForData]", "NameOfTableContainingData","WhereCondition(s)")

So for what you're doing, you'd want this:
Code:
DLookup("PLANNEDSTARTDATE","PRISM_SAMPLEDATE","[JobNumber] = " & [Forms]![Design_Detail_ProjectManagement]![JobNumber])
 
Here's a Dlookup reference guide: http://www.techonthenet.com/access/functions/domain/dlookup.php

It takes 3 arguments in this order--field name, data source, criteria. I believe you have reversed the first 2. You put the field name where the data source goes and vice versa.

Additionally, in your criteria argument you are comparing [JobNumber] as if it was a numeric field. Is [JobNumber] actually a numeric datatype? If not, you need to put single quotes to escape the data coming from the form.
 
Proper use of Dlookup is NEVER USE IT... well use it sparingly so think about this again before you actually use it...

DLookup(expr, domain [, criteria] )

expr is a column name
Domain is table/query name
criteria is obvious

You seem to have flipped the first 2

Edit: Duh ^2, Plog and Frothing beat me to it :(
 

Users who are viewing this thread

Back
Top Bottom