Results 1 to 5 of 5
  1. #1
    DebbieC is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Jan 2012
    Posts
    3

    Parameter Form

    I have a single Access report which is based on a query and I am trying to add a parameter for one of the fields (Dept) so that the user can run the report for the one Dept they specify rather than all depts.
    I have created a form with a combo box which lists the options they can choose from and I have linked this form and control to the query in the report ‘[Forms]![InputDept]![Combo14]’. I have two buttons on the form: one I have called ‘Ok’ and one I have called ‘Cancel’. For both buttons the event ‘On click’ is linked to a macro.
    ‘OK’ macro hides the form when the user clicks the Ok button.
    ‘Cancel’ macro closes the form when the user clicks the Cancel button.

    When I run the report the form opens and the report correctly filters for the dept which has been selected in the parameter form. The problem I have is when I go to print preview the form....the parameter form opens again. And it also opens when I close print preview. Is this because I have just hidden the form? It doesn't appear to be 'active' because if i change the dept that is selected the print preview page is displayed showing the dept originally selected when the report was run.

    In the events tab in the properties section of the form I have a macro ‘Open Dialog’ on the ‘On Open’ event which opens the parameter form.


    I have attached the Open Dialog and OK macros.
    Attachment 5991

    Attachment 5992
    I’m not that familiar with Visual Basic and this is the first time I have used a parameter form with a report.
    Any help would be appreciated.
    Thanks in advance

  2. #2
    aytee111 is offline Competent At Times
    Windows 7 32bit Access 2010 32bit
    Join Date
    Nov 2011
    Location
    Nomad
    Posts
    3,936
    You are making this more difficult than it needs to be. On the form have two buttons, one for Print and one for Print Preview. If they don't want either they can close the form (instead of having a Cancel button). VBA is not required.

  3. #3
    DebbieC is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Jan 2012
    Posts
    3
    I've tried adding a button for print preview but it doesn't work. It comes up with a message saying you cannot switch to a different view at this time. Is this because the report hasn't ran yet?
    How do I add a button that will open the report in print preview mode as the default? I'm not sure what the sequence of actions are?
    Thanks

  4. #4
    aytee111 is offline Competent At Times
    Windows 7 32bit Access 2010 32bit
    Join Date
    Nov 2011
    Location
    Nomad
    Posts
    3,936
    The best thing to do is to use the button wizard - when you create the button control on the form it will ask you what you want the button to do and then it will create the macro for you. Try recreating the buttons and see if this solves your problems.

  5. #5
    DebbieC is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Jan 2012
    Posts
    3
    Thanks.
    I've managed to resolve this. I've added buttons to 'OpenReport' in the Print Preview mode. The user runs the report from the form now and not from the report which is what I had before.

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

Similar Threads

  1. Replies: 13
    Last Post: 01-10-2012, 09:56 AM
  2. Parameter field in Form
    By darryaz in forum Forms
    Replies: 2
    Last Post: 11-20-2011, 12:38 PM
  3. Form combo box - All or parameter
    By Dega in forum Forms
    Replies: 9
    Last Post: 08-28-2011, 07:49 PM
  4. Replies: 10
    Last Post: 09-27-2010, 08:06 PM
  5. Pull Parameter Value from Form
    By dymondjack in forum Queries
    Replies: 1
    Last Post: 02-14-2007, 07:15 PM

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