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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

DLookup Syntax 1

Status
Not open for further replies.

Rjc8513

Technical User
Feb 12, 2001
140
0
0
US
I'm attempting to use DLookup in a text box on a report and keep getting "#Error" returned. Can someone help with the proper syntax?

="Week No " & DLookup("[WEEK]","[tbl DATES]","[YRDAYWK]=" & "[tbl EMPLOYEE DATA].[YRDAYWK]")

Thanks.
 
Your syntax is the same as
[tt][blue]="Week No " & DLookup("[WEEK]","[tbl DATES]","[YRDAYWK]=[tbl EMPLOYEE DATA].[YRDAYWK]")[/blue][/tt]

If YRDAYWK is a numeric field in your report's record source, then try:
[tt][blue]="Week No " & DLookup("[WEEK]","[tbl DATES]","[YRDAYWK]=" & [YRDAYWK])[/blue][/tt]

If it is text, try:
[tt][blue]="Week No " & DLookup("[WEEK]","[tbl DATES]","[YRDAYWK]='" & [YRDAYWK] & "'")[/blue][/tt]


Duane MS Access MVP
[green]Ask a great question, get a great answer.[/green] [red]Ask a vague question, get a vague answer.[/red]
[green]Find out how to get great answers faq219-2884.[/green]
 
Thanks for the response Duane but that didn't work.

"YRDAYWK" is text and is not a field in the report's record source.
 
Where do you expect the value of YRDAYWK to come from?

Duane MS Access MVP
[green]Ask a great question, get a great answer.[/green] [red]Ask a vague question, get a vague answer.[/red]
[green]Find out how to get great answers faq219-2884.[/green]
 
The report's record source is a crosstab query. The field "YRDAYWK" is a field in the table that supplies the crosstab query.

I want the lookup to find the corresponding value in the "YRDAYWK" field of the "tbl DATES" table.
 
If YRDAYWK is not in the report's record source then where does the value come from that you want to "lookup to find the corresponding value in the "YRDAYWK" field of the "tbl DATES" table"?

Can you add "tbl Dates" to your crosstab query?

Duane MS Access MVP
[green]Ask a great question, get a great answer.[/green] [red]Ask a vague question, get a vague answer.[/red]
[green]Find out how to get great answers faq219-2884.[/green]
 
The "tbl EMPLOYEE DATA" table has a "YRDAYWK" field and the value of the field is identical for every record in the table.

I want to use that field value as the criteria for the lookup to find the corresponding record in the
"[tbl DATES].[YRDAYWK]" field to return the "WEEK" field value.

Hope this makes sense.
 
Create a query
Code:
SELECT WEEK
FROM [tbl EMPLOYEE DATA] JOIN [tbl DATES] ON  [tbl EMPLOYEE DATA].YRDAYWK = [tbl DATES].YRDAYWK
GROUP BY WEEK;
Then add this query which should return a single record to the record source of your report.

Duane MS Access MVP
[green]Ask a great question, get a great answer.[/green] [red]Ask a vague question, get a vague answer.[/red]
[green]Find out how to get great answers faq219-2884.[/green]
 
That did it, Duane!

Thanks so much for your help and your patience.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top