Results 1 to 4 of 4
  1. #1
    Robert M is offline Novice
    Windows XP Access 2003
    Join Date
    Jun 2009
    Posts
    23

    OpenReport Command with Double Check Where Statement

    Private Sub cmdPrintRpt_Click()
    On Error GoTo Err_cmdPrintRpt_Click
    Dim stDocName As String

    stDocName = "CPEReport"
    docmd.OpenReport stDocName, acPreview, , "LastNameInitl = '" & Me.LastNameInitl & "'"

    Exit_cmdPrintRpt_Click:
    Exit Sub
    Err_cmdPrintRpt_Click:
    MsgBox "No Program or Sponsor Data Entered for this Attendee"


    Resume Exit_cmdPrintRpt_Click

    End Sub

    I am using the above program to print a report based on the Name of the individual wanting the report. However I am now needing to have two where conditions "Name Field and Y/N field" to generate the report in the form I am wanting.
    I am not sure of the syntax of the Open Report,,,Where Statement to generate the Type of Report I am wanting.

    Thank you for your help in this matter

    Robert M

  2. #2
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 10 Access 2013 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    Something like:
    Code:
    Private Sub cmdPrintRpt_Click()
       On Error GoTo Err_cmdPrintRpt_Click
       Dim strDocName As String
       Dim strWhere As String
       strDocName = "CPEReport"
       strWhere = "LastNameInitl = '" & Me.LastNameInitl & "' AND [YourField] = True"
       DoCmd.OpenReport strDocName, acPreview, , strWhere
    Exit_cmdPrintRpt_Click:
       Exit Sub
    Err_cmdPrintRpt_Click:
       MsgBox "No Program or Sponsor Data Entered for this Attendee"
       Resume Exit_cmdPrintRpt_Click
    End Sub

  3. #3
    Robert M is offline Novice
    Windows XP Access 2003
    Join Date
    Jun 2009
    Posts
    23
    Thanks RuralGuy That looks like what I am needing.

    Robert M

  4. #4
    RuralGuy's Avatar
    RuralGuy is offline Administrator
    Windows 10 Access 2013 32bit
    Join Date
    Mar 2007
    Location
    8300' in the Colorado Rocky Mountains
    Posts
    12,922
    You're welcome. Have fun.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 7
    Last Post: 12-10-2018, 05:24 PM
  2. Can docmd.openreport print X copies on Y printer?
    By Coolpapabell in forum Reports
    Replies: 1
    Last Post: 09-02-2009, 08:35 AM
  3. double booked entries
    By qbc in forum Access
    Replies: 3
    Last Post: 08-28-2009, 10:30 AM
  4. Can I pass "sort by" using DoCmd.OpenReport
    By alsoto in forum Reports
    Replies: 3
    Last Post: 04-16-2009, 08:11 PM
  5. Replies: 0
    Last Post: 05-17-2008, 01:18 AM

Tags for this Thread

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums