Opening a report from a form with 2 criteria

  • Thread starter Thread starter tgavin
  • Start date Start date
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
 
I think the "AND" needs to be inside the quotes as well.

try

stLinkCriteria = "[PayWeek]=" & "#" & Me![PayWeek] & "# And [RCCode]="
& "'" & Me![RCCode] & "'"
 
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] & "'"
 
Back
Top