Look for date data in field

  • Thread starter Thread starter Ken Ivins
  • Start date Start date
K

Ken Ivins

I want to look to a table and see if there is a specific date in that field.
If there is then do one thing and if not do another.

I did a dlookup (trying to get a null value or string value) and got an
error that the data type did not match. I saw another post that the date
need to be formated but when I tried to do that I got errors on that as
well.

varX = DLookup("biLstNam", "[tblBilling]", "biDate='" & Me.txbBillingDate &
"'")

What am I doing wrong or is there a better way to do this?


Thanks,
Ken
 
varX = DLookup("biLstNam", "[tblBilling]",
"biDate=#" & Me.txbBillingDate & "#")

Dates are delimited with # characters. Also, Access expects date strings to be
in mm/dd/yyyy format.

Another way to do this:
varX = DLookup("biLstNam", "[tblBilling]",
"biDate=" & Format(Me.txbBillingDate,"\#mm\/dd\/yyyy\#"))
 
John,

I had seen the second solution and had trouble with that as well. But your
first solution worked fine and did what I needed

Thanks for your help,
Ken

John Spencer (MVP) said:
varX = DLookup("biLstNam", "[tblBilling]",
"biDate=#" & Me.txbBillingDate & "#")

Dates are delimited with # characters. Also, Access expects date strings to be
in mm/dd/yyyy format.

Another way to do this:
varX = DLookup("biLstNam", "[tblBilling]",
"biDate=" & Format(Me.txbBillingDate,"\#mm\/dd\/yyyy\#"))

Ken said:
I want to look to a table and see if there is a specific date in that field.
If there is then do one thing and if not do another.

I did a dlookup (trying to get a null value or string value) and got an
error that the data type did not match. I saw another post that the date
need to be formated but when I tried to do that I got errors on that as
well.

varX = DLookup("biLstNam", "[tblBilling]", "biDate='" & Me.txbBillingDate &
"'")

What am I doing wrong or is there a better way to do this?

Thanks,
Ken
 
Back
Top