Results 1 to 5 of 5
  1. #1
    ScottySchultz is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jan 2018
    Posts
    8

    OpenReport Macro


    I've created a form which you can enter one of three different search criteria and OpenReport OnClick event to open a report based on that criteria. Is there a 'where condition' statement that I can use to search my table and bring up the report of the record that contains the data, regardless of which of the three criteria are entered. I am limiting the user to enter only one of the 3 criteria to search and I'd like to avoid using 3 search buttons (one for each criteria).
    Thanks!

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,521
    you wouldnt search the report, youd search the query (behind the report).
    so you could code to find the item:

    Code:
    if not IsNull(Dlookup("[field]","query1","[name]='" & txtBox & "'")) then docmd.openReport "report1"
    if not IsNull(Dlookup("[field]","query2","[name]='" & txtBox & "'")) then docmd.openReport "report2"
    if not IsNull(Dlookup("[field]","query3","[name]='" & txtBox & "'")) then docmd.openReport "report3"

  3. #3
    ScottySchultz is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jan 2018
    Posts
    8
    so you're saying it's better to search a query rather than the table itself? and this code will work in inserted into the macro builder? or does it need to be VBA?

  4. #4
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,521
    either way. if the report uses a query, use the query.

    the code can work either way, macros or vba.

  5. #5
    ScottySchultz is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jan 2018
    Posts
    8
    Thanks for sharing!

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

Similar Threads

  1. Help with an OpenReport Where Condition
    By hehrerh in forum Reports
    Replies: 1
    Last Post: 06-29-2017, 08:56 AM
  2. OpenReport macro question
    By chdui in forum Forms
    Replies: 3
    Last Post: 05-12-2015, 10:00 AM
  3. OpenReport cancelled
    By wharting in forum Reports
    Replies: 15
    Last Post: 11-11-2011, 02:34 PM
  4. Pausing OpenReport
    By EES in forum Reports
    Replies: 5
    Last Post: 06-15-2011, 05:30 PM
  5. OpenReport function
    By grad2009 in forum Access
    Replies: 8
    Last Post: 05-22-2010, 10:43 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