Solved Dlookup Using Date/Time (1 Viewer)

Eureka99

New member
Local time
Today, 12:54
Joined
Jun 29, 2020
Messages
26
Hi Guys,

I need help with a DLookup

I'm trying to use a dlookup to assign a value based on a date so I can use this in a query later as a condition on whether or not its greater.

For example I have a table filled with Dates and values - So I've called this Tbl_Dex and it has 3 fields: ID, Day1 (Date/ Time), Exchange (Number)

so my first record is ID=1, Day1 = 01/02/2022 and Exchange = 1 The each new record increments by 1 month and exchange value increments by 1.


I then have subform query that needs a month / Year filter - for which I have used 2 text boxes, with a third hidden box turning them into a date, which is what I will use as my query condition.

The problem is, I'm trying to use a Dlookup to return the exchange value but it's not working. I've never really done dlookups on dates before, just strings. Can anyone help?

Code:
dex1 = DateSerial(Me.Text4, Me.Text2, 1)

Text11 = DLookup("Exchange", "Tbl_DEX", [day1]= & [dex1])
 

Eureka99

New member
Local time
Today, 12:54
Joined
Jun 29, 2020
Messages
26
Ignore me guys - I've made this more complicated then I needed to!!
 

Gasman

Enthusiastic Amateur
Local time
Today, 12:54
Joined
Sep 21, 2011
Messages
14,234
Even so...
Strings need to be surrounded by single quotes ' unless it contains a single quote, then triple double quotes works, I think?

Dates with # and in mm/dd/yyyy or yyyy-mm-dd format

Numbers do not need anything
 

Users who are viewing this thread

Top Bottom