DLookup Problem

  • Thread starter Thread starter Frank Stone
  • Start date Start date
F

Frank Stone

I am stumped on this one. I have a form that looks like a
calendar. I have a table with our company holidays. as the
calendar is populated with the month, I want to check the
holiday table and if that is a match, color the calendar
day box red. I am useing DLookup

If DLookup("[HDate]", "tblCalendarHolidays", "[HDate] = '"
& Me.txtD1 & "'") Then
Me("C" & Format(D3, "00")).ForeColor = 255
End If
HDate is the holiday date field
tblcalendarHolidays is the table
Me.txtD1 is the control text box on the form that has the
date i want to check match on.
when i run the code i get a error on DLookup.
Run Tiem Error 62506 - Data type mismatch in criteria
expression.
HDate is formated at Date/time - short date
Me.txtD1 is formated to short date.
I don't understand why i am getting this error. any
suggestions?
 
Hi Frank,

Try replacing the apostrophes surrounding your date value
with # signs. In access, pound signs are used to signify
date values similar to the way apostrophes or quotes are
used to denote string values.

HTH, Ted Allen
 
that did it! thanks Ted. I was about to use the fire axe
method to fix this one. much much appreciated.
-----Original Message-----
Hi Frank,

Try replacing the apostrophes surrounding your date value
with # signs. In access, pound signs are used to signify
date values similar to the way apostrophes or quotes are
used to denote string values.

HTH, Ted Allen
-----Original Message-----
I am stumped on this one. I have a form that looks like a
calendar. I have a table with our company holidays. as the
calendar is populated with the month, I want to check the
holiday table and if that is a match, color the calendar
day box red. I am useing DLookup

If DLookup("[HDate]", "tblCalendarHolidays", "[HDate] = '"
& Me.txtD1 & "'") Then
Me("C" & Format(D3, "00")).ForeColor = 255
End If
HDate is the holiday date field
tblcalendarHolidays is the table
Me.txtD1 is the control text box on the form that has the
date i want to check match on.
when i run the code i get a error on DLookup.
Run Tiem Error 62506 - Data type mismatch in criteria
expression.
HDate is formated at Date/time - short date
Me.txtD1 is formated to short date.
I don't understand why i am getting this error. any
suggestions?
.
.
 
My pleasure, glad it helped.

-Ted Allen
-----Original Message-----
that did it! thanks Ted. I was about to use the fire axe
method to fix this one. much much appreciated.
-----Original Message-----
Hi Frank,

Try replacing the apostrophes surrounding your date value
with # signs. In access, pound signs are used to signify
date values similar to the way apostrophes or quotes are
used to denote string values.

HTH, Ted Allen
-----Original Message-----
I am stumped on this one. I have a form that looks
like
a
calendar. I have a table with our company holidays. as the
calendar is populated with the month, I want to check the
holiday table and if that is a match, color the calendar
day box red. I am useing DLookup

If DLookup("[HDate]", "tblCalendarHolidays", "[HDate] = '"
& Me.txtD1 & "'") Then
Me("C" & Format(D3, "00")).ForeColor = 255
End If
HDate is the holiday date field
tblcalendarHolidays is the table
Me.txtD1 is the control text box on the form that has the
date i want to check match on.
when i run the code i get a error on DLookup.
Run Tiem Error 62506 - Data type mismatch in criteria
expression.
HDate is formated at Date/time - short date
Me.txtD1 is formated to short date.
I don't understand why i am getting this error. any
suggestions?
.
.
.
 
Back
Top