Dlookup with Date/Time datatype

gwunta1907

Registered User.
Local time
Today, 18:55
Joined
Jan 11, 2007
Messages
26
hi guys, I'm trying to do a DLookup specifying two criteria. The first criterion is a text field an the second is a Date field. Im sure I have the syntax wrong as the error Im getting is a Type mismatch error. Ive checked both tables where I am comparing data and they are both set to Date/Time datatypes. The current syntax I have is:

Me.exin = DLookup("USD_Equivalent", "tbl_rated", "Currency Like """ & Me.Currency_Name & """" And "Dated Like """ & Me.SailingDate & """")

Do I just replace the amphersands &'s surrounding Me.SailingDate or is there more to is than that?

Many thanks in advance
 
Me.exin = DLookup("USD_Equivalent", "tbl_rated", "Currency Like """ & Me.Currency_Name & """" And "Dated Like """ & Me.SailingDate & """")

should be

Code:
Me.exin = DLookup("USD_Equivalent", "tbl_rated", "Currency = """  & Me.Currency_Name & """ And Dated = #" &  Me.SailingDate & "#")
let me know if that works
 
Yeah I had a look at that before I posted pbaldy, but still having problems.

I tried this:

Me.exin = DLookup("USD_Equivalent", "tbl_rated", "Currency Like """ & Me.Currency_Name & """" AND "Dated = # Me.SailingDate #")

But still get a type mismatch error
 
grzzlo has given you your fish.
 
Success!! Thankyou grzzlo, I must having been writing my previous post while you were posting. Thankyou again for your help, the learning curve is steep at the moment for me haha
 
Dates need to be surround by the date identifier (#), so your DLookup should look like;
Code:
Me.exin = DLookup("USD_Equivalent", "tbl_rated", "Currency Like '" & Me.Currency_Name & "' And Dated Like #" & Me.SailingDate & "#")
 
Too slow
headbang.gif
 

Users who are viewing this thread

Back
Top Bottom