Results 1 to 3 of 3
  1. #1
    snipe's Avatar
    snipe is offline Competent Performer
    Windows 7 64bit Access 2010 32bit
    Join Date
    Sep 2013
    Posts
    287

    DoCmd.OpenReport Where Argument


    Hey guys,

    How exactly does the Where argument work?

    For example: I have a query that is ran for sales data. It includes our 3 states: Texas, Florida, Utah. Those states are spelled out like that in the Region field of the query.

    I was hoping to only have 1 query, 1 report design, and 3 lines of DoCmd.OpenReport to print out the report for each state.

    This is hypothetical, as my process is a bit more complex, but I just need to learn the syntax.

  2. #2
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 7 64bit Access 2010 32bit
    Join Date
    Aug 2013
    Posts
    7,862
    Dim strReport as string
    dim strWhere as string

    strReport = "MyReportName"
    strWhere = "[StatePK] = " & Me.StatePK

    DoCmd.OpenReport "strReport", acViewPreview, , strWhere

  3. #3
    snipe's Avatar
    snipe is offline Competent Performer
    Windows 7 64bit Access 2010 32bit
    Join Date
    Sep 2013
    Posts
    287
    Awesome! Nice and easy. Appreciate the help!

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

Similar Threads

  1. DoCmd.OpenForm; 3rd Argument = FilterName
    By Access_Novice in forum Programming
    Replies: 1
    Last Post: 02-02-2014, 11:05 PM
  2. doCmd.OpenReport - Multiple Where Conditions
    By jml9012 in forum Programming
    Replies: 10
    Last Post: 05-20-2013, 08:45 PM
  3. DoCmd.OpenReport WHERE condition
    By bidbud68 in forum Programming
    Replies: 16
    Last Post: 10-19-2012, 05:31 AM
  4. Need help w/ docmd.openreport
    By jwill in forum Reports
    Replies: 3
    Last Post: 06-04-2012, 09:49 PM
  5. DoCmd OpenReport ... where condition with a Like
    By Grooz13 in forum Programming
    Replies: 4
    Last Post: 08-31-2010, 09:04 AM

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