Dlookup (1 Viewer)

newbie786

New member
Local time
Today, 09:12
Joined
Jul 7, 2015
Messages
8
Hi I cant seem to get my head round this, im trying to lookup 2 fields in a xls file with 2 criteria's in my dlookup,

this is what my code looks like for lookup of 1 field;

=Dlookup("morning","JulyLinked',"day=" & day(date()))

this works for looking up the day field in the linked table julylinked and matching this up with the day in that day.


but what im trying to do is match up the day as well as the month so my code looks something like this:

=Dlookup("morning","JulyLinked',"day=" & day(date())and "month=" & month(date()))

but doesnt work

any ideas?
 

bob fitz

AWF VIP
Local time
Today, 09:12
Joined
May 23, 2011
Messages
4,717
Does JulyLinked have a field called Month
B.T.Y. Day and Month are reserved words and should not be used as field names.
 

newbie786

New member
Local time
Today, 09:12
Joined
Jul 7, 2015
Messages
8
Hi Bob_fitz

The fields in JulyLinked are Day and month, I have tried to change them but still not working
 

Pat Hartman

Super Moderator
Staff member
Local time
Today, 05:12
Joined
Feb 19, 2002
Messages
42,970
What did you change them to? Always post the latest version of your code after making a change so we don't have to guess.
 

JHB

Have been here a while
Local time
Today, 10:12
Joined
Jun 17, 2012
Messages
7,732
You've the " in the wrong place and you're missing a &, change it to the below:
Code:
=Dlookup("morning","JulyLinked',"day=" & day(date()) [B][COLOR=Red]& "[/COLOR][/B] and month=" & month(date()))
Looking at your table name JulyLinked make me suspicious that you have a table for each month and that is incorrect in database context.
 

Gasman

Enthusiastic Amateur
Local time
Today, 09:12
Joined
Sep 21, 2011
Messages
14,037
JHB,
I believe it would be linked to this thread https://www.access-programmers.co.uk/forums/showthread.php?p=1583041#post1583041

You've the " in the wrong place and you're missing a &, change it to the below:
Code:
=Dlookup("morning","JulyLinked',"day=" & day(date()) [B][COLOR=Red]& "[/COLOR][/B] and month=" & month(date()))
Looking at your table name JulyLinked make me suspicious that you have a table for each month and that is incorrect in database context.
 

Users who are viewing this thread

Top Bottom