Type Mismatch---Run-Time Error '13'

  • Thread starter Thread starter Jan
  • Start date Start date
J

Jan

Hello,

I am trying to run a report using the Where condition. I
have set 2 conditions and independently, they work fine.
However, when I combine them I get a type mismatch. Could
anyone look at the code below and help me figure out where
I have gone wrong?

DoCmd.OpenReport "rptPackaging",acViewPreview,
, "[Quality Agreement at Supplier] = 'Yes'"
And "[Year] '2003'"

Thanks in advance,
Jan
 
DoCmd.OpenReport "rptPackaging",acViewPreview, , _
"[Quality Agreement at Supplier] = 'Yes' AND [Year] '2003'"
This assumes both fields are text.
 
Shouldn't there be an equal sign between [Year] and '2003':

DoCmd.OpenReport "rptPackaging",acViewPreview, , _
"[Quality Agreement at Supplier] = 'Yes' AND [Year] = '2003'"


--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)



Duane Hookom said:
DoCmd.OpenReport "rptPackaging",acViewPreview, , _
"[Quality Agreement at Supplier] = 'Yes' AND [Year] '2003'"
This assumes both fields are text.

--
Duane Hookom
MS Access MVP


Jan said:
Hello,

I am trying to run a report using the Where condition. I
have set 2 conditions and independently, they work fine.
However, when I combine them I get a type mismatch. Could
anyone look at the code below and help me figure out where
I have gone wrong?

DoCmd.OpenReport "rptPackaging",acViewPreview,
, "[Quality Agreement at Supplier] = 'Yes'"
And "[Year] '2003'"

Thanks in advance,
Jan
 
oops. Thanks Doug.

--
Duane Hookom
MS Access MVP
--

Douglas J. Steele said:
Shouldn't there be an equal sign between [Year] and '2003':

DoCmd.OpenReport "rptPackaging",acViewPreview, , _
"[Quality Agreement at Supplier] = 'Yes' AND [Year] = '2003'"


--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)



Duane Hookom said:
DoCmd.OpenReport "rptPackaging",acViewPreview, , _
"[Quality Agreement at Supplier] = 'Yes' AND [Year] '2003'"
This assumes both fields are text.

--
Duane Hookom
MS Access MVP


Jan said:
Hello,

I am trying to run a report using the Where condition. I
have set 2 conditions and independently, they work fine.
However, when I combine them I get a type mismatch. Could
anyone look at the code below and help me figure out where
I have gone wrong?

DoCmd.OpenReport "rptPackaging",acViewPreview,
, "[Quality Agreement at Supplier] = 'Yes'"
And "[Year] '2003'"

Thanks in advance,
Jan
 
Back
Top