WhereCondition with a Type Mismatch error

eRed

Registered User.
Local time
Today, 16:40
Joined
Oct 27, 2010
Messages
15
Please help :confused:

This works


DoCmd.OpenReport "ReportName", acViewPreview, , "[ReportName].[FieldID]=" & Me.FieldID

and this works

DoCmd.OpenReport "ReportName", acViewPreview, , "[ReportName].[DateRec]= #" & Me.[DateRec] & "#"


But this doesn't work

DoCmd.OpenReport "ReportName", acViewPreview, , "[ReportName].[FieldID]=" & Me.FieldID And "[ReportName].[DateRec]= #" & Me.[DateRec] & "#"


Run-time error '13';

Type mismatch

Thank you
 
Try;
Code:
DoCmd.OpenReport "ReportName", acViewPreview, , "[ReportName].[FieldID]=" & Me.FieldID  And [B][COLOR="Red"]&[/COLOR][/B] "[ReportName].[DateRec]= #" & Me.[DateRec] & "#"
 
E,

Code:
DoCmd.OpenReport "ReportName", acViewPreview, , "[ReportName].[FieldID]=" & Me.FieldID [B][SIZE="3"]& " And " &[/SIZE][/B] [ReportName].[DateRec] =  #" & Me.[DateRec] & "#"

hth,

Wayne
 
Thank you very much...

this was the code that worked:

DoCmd.OpenReport "ReportName", acViewPreview, , "[ReportName].[FieldID]=" & Me.FieldID & " And " & "[ReportName].[DateRec] = #" & Me.[DateRec] & "#"

Thanks again!

E
 
eRed,

I have a little stupid comment on your conclusion:

you could use:
... & "And [Control] ....
Instead of:
... & " And " & "[Control] ....
 
eRed,

I have a little stupid comment on your conclusion:

you could use:
... & "And [Control] ....
Instead of:
... & " And " & "[Control] ....

That's not a stupid comment. It is a good comment and the method that I use. No need to concatenate strings together when you can just have one string.
 

Users who are viewing this thread

Back
Top Bottom