Opening a report from a form with 2 criteria

T

tgavin

I want to open a report and pull up specific data based on fields in the
form. I do this all the time but in this case, I need the link criteria to
have 2 criteria. When I pull for either one separately, it works fine but
when I do it for both of them, I get a Type Mismatch error message. The code
I am using is:

Dim stDocName As String
Dim stLinkCriteria As String

stDocName = "rptTimeSheet"
stLinkCriteria = "[PayWeek]=" & "#" & Me![PayWeek] & "#" And "[RCCode]="
& "'" & Me![RCCode] & "'"

DoCmd.OpenReport stDocName, acPreview, , stLinkCriteria

Could you help?

Thanks
 
G

ghetto_banjo

I think the "AND" needs to be inside the quotes as well.

try

stLinkCriteria = "[PayWeek]=" & "#" & Me![PayWeek] & "# And [RCCode]="
& "'" & Me![RCCode] & "'"
 
G

ghetto_banjo

actually there might be an issue with your delimiters as well, but
maybe you just have extra quotes.


stLinkCriteria = "[PayWeek]= #" & Me![PayWeek] & "# And [RCCode]
= '" & Me![RCCode] & "'"
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top