[Okta Webinar] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 302
  • Last Modified:

Access VBA syntax for printing report

Hello
Thank you in advance for your help.

I am trying to print a report with VBA that restricts the output to one specific test. I am getting a type mismatch error. I think I am using the syntax for a string. The data is an integer. Below is the code that gives a type mismatch error.

Dim stDocName As String
    Dim intLinkCriteria As Integer

    stDocName = "Result Letter"
   
    intLinkCriteria = "[Test Number]=" & "'" & Me![Test Number] & "'"
   
    DoCmd.OpenReport stDocName, acViewPreview, , stLinkCriteria

What would be the correct syntax?

thanks
Bob
0
Rwardlow
Asked:
Rwardlow
  • 2
1 Solution
 
mbizupCommented:
   intLinkCriteria = "[Test Number]="  & Me![Test Number]
0
 
mbizupCommented:
   Dim strLinkCriteria As String

    stDocName = "Result Letter"
   
    strLinkCriteria = "[Test Number]=" &  Me![Test Number]
   
    DoCmd.OpenReport stDocName, acViewPreview, , strLinkCriteria

0
 
RwardlowAuthor Commented:
Thanks
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now