Help On Syntax Error For Queries

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I would like to know how come I got the error "Data Type Mismatch In Criteria
Expression". Both [DateEntered] And [HoliDate] are fields in Date / Time
(Short Date). I just need to compare the 2 date and produce a yes if they
are the same or no if they are not the same in the table. Please Help me.

UPDATE TimeCard, Holidays SET TimeCard.PH = Yes
WHERE (((TimeCard.PH)=IIf(("#" & [DateEntered] & "#" = "#" & [HoliDate] &
"#"),"Yes","No")));
 
Seikyo,

What is the function of the Holidays table? Are Ph, DateEntered, and
HoliDate, all fields in the TimeCard table. If not, what is the
relationship between the two tables. I am not clear what you are trying
to achieve, so this is only a guess...

UPDATE TimeCard SET [PH] = Yes
WHERE [DateEntered] = [HoliDate] = True
 
I think I use another method to solve it. I create a query to put "0" in a
additional field in my main table. Then I compare the date, if they are
equal, I put "-1" else it remain "0". To count the number of holiday, I put
the count function to count the number of "-1" and display on the report.

Anyway, Thanks for enlighten me with the code. Thanks You.

Steve Schapel said:
Seikyo,

What is the function of the Holidays table? Are Ph, DateEntered, and
HoliDate, all fields in the TimeCard table. If not, what is the
relationship between the two tables. I am not clear what you are trying
to achieve, so this is only a guess...

UPDATE TimeCard SET [PH] = Yes
WHERE [DateEntered] = [HoliDate] = True

--
Steve Schapel, Microsoft Access MVP

I would like to know how come I got the error "Data Type Mismatch In Criteria
Expression". Both [DateEntered] And [HoliDate] are fields in Date / Time
(Short Date). I just need to compare the 2 date and produce a yes if they
are the same or no if they are not the same in the table. Please Help me.

UPDATE TimeCard, Holidays SET TimeCard.PH = Yes
WHERE (((TimeCard.PH)=IIf(("#" & [DateEntered] & "#" = "#" & [HoliDate] &
"#"),"Yes","No")));
 
Back
Top