Results 1 to 8 of 8
  1. #1
    B30 is offline Novice
    Windows Vista Access 2007
    Join Date
    Sep 2014
    Posts
    21

    Macro to open form when a report is selected

    I have a report that is based on a query. The query has filters in it based on user info entered from a form. So the form asks the user to select which division of the company, and the date range for when the info applied to. My issue is that I am trying to set a macro that opens this form whenever some tries to open the report. But the macro appears to run the query before it opens the form and it gives me a generic message box asking for the division. After I type that in (instead of selecting from a drop down list like I have on my form) another window pops up asking for start date, etc...instead of opening the form I created. What am i doing wrong and how do I get the macro to open my form? If I open the form directly and enter the criteria, it runs the report correctly.

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    8,185
    Open the form. (not the report)
    Then on the form, open the report after all items are picked.

  3. #3
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    49,150
    What is this macro connected to - a button on another form? As ranman suggests, change the macro code to open form. Code behind this form should open report.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  4. #4
    B30 is offline Novice
    Windows Vista Access 2007
    Join Date
    Sep 2014
    Posts
    21
    Right now, I have the On Load event in the report set to run the macro OpenForm. The OpenForm macro is set to open the form that defines the filter criteria in the query. I am trying to make this idiot proof and I think the only thing I am accomplishing is proving that I am the idiot. Basically, If someone wants to open the report I want them to fill out the form first. That is why I am trying to tie the macro to the report, so that if they try to open the report they have to go through the form.

  5. #5
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    49,150
    Doesn't make sense to open report before opening the form for input of filter criteria.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  6. #6
    B30 is offline Novice
    Windows Vista Access 2007
    Join Date
    Sep 2014
    Posts
    21
    That is why I am trying to make the form open if someone tries to open the report. Most of the people who will run this report have never used access before, so they dont know the difference between a form and report. Am I missing a step in the macro that tells it to open the form before it looks at the query? Or do I need to put the macro somewhere other than in the On Load event? Is it easier to have a msgbox open when they click on the report to tell them to open the form? Maybe with a command button that opens the form?

  7. #7
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    49,150
    Report is bound to query, opening report 'runs' the query. Parameters are not available to the query so when the report opens it prompts for the missing info.

    Regardless of what the button caption says, must open the search form first. User inputs criteria then clicks another button "Done" or "Continue" to open the report, form must remain open.

    I personally don't like and never use dynamic parameterized queries. I also don't use macros.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  8. #8
    B30 is offline Novice
    Windows Vista Access 2007
    Join Date
    Sep 2014
    Posts
    21
    Thanks. I guess I can just hide everything except the form so they have to go through it.

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

Similar Threads

  1. Macro to open report based on value in a form
    By iProRyan in forum Macros
    Replies: 2
    Last Post: 02-24-2014, 03:02 AM
  2. Replies: 5
    Last Post: 06-19-2013, 08:01 AM
  3. Macro - Open Report, SetValue
    By NLA in forum Programming
    Replies: 1
    Last Post: 11-17-2012, 09:53 PM
  4. Replies: 3
    Last Post: 09-20-2012, 11:09 AM
  5. Replies: 7
    Last Post: 05-01-2012, 11: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 - Senior Forums