Results 1 to 11 of 11
  1. #1
    RobRay is offline Novice
    Windows XP Access 2003
    Join Date
    Oct 2010
    Posts
    11

    Choose Parameter combo box for report

    Hi, I would like to make the Choose Parameter box into a combo box, I've been trying to use a form to no avail so far, and if it does work, it still opens a Choose Parameter box, then opens the query as well as the report.
    Here's the code I've been playing with, a.t.m. the Run my Report button does nothing, so I click cancel and then the Choose Parameter box pops up.


    Option Compare Database
    Private Sub Report_Close()
    DoCmd.Close acForm, "ChooseForm"
    End Sub
    Private Sub Report_Open(Cancel As Integer)
    ' Set public variable to true to indicate that the report
    ' is in the Open event
    bInReportOpenEvent = True
    ' Open Sales By Category Dialog
    DoCmd.OpenForm "ChoosePark", , , , , acDialog

    ' Set public variable to false to indicate that the
    ' Open event is completed
    bInReportOpenEvent = False
    End Sub



    I just want to choose from a drop down box and have the corresponding report appear with all of it's subreports referring to the same thing.

    How can I do this?



    Thanks!
    Last edited by RobRay; 10-29-2010 at 11:02 AM.

  2. #2
    NTC is offline VIP
    Windows Vista Access 2007
    Join Date
    Nov 2009
    Posts
    2,392
    Your post is unclear. Generically, a Report has a record source (table or query).

    If you have multiple reports - then one could, as you suggest, set up a dropdown (combo or list box) to select which report to open; rather than having an Open button per report.

    If you instead have a single report - but want it to report on differing data; which is common; then you have to vary the parameter of the underlying query record source so that the record source has differing data. This can also be done via a dropdown type control.

    One should have a textbook, easily found at Amazon or any big book store that will have examples of a parameter query and calling parameters from form controls.

    Hope this helps.

  3. #3
    RobRay is offline Novice
    Windows XP Access 2003
    Join Date
    Oct 2010
    Posts
    11
    Sorry about the clarity I'll try again:

    I do have a single report, and I want it to report on differing data.
    The trouble I am having is getting the underlying query recordsource to vary its data by a drop down box.

    I've tried [Form]![ChoosePark]![ParkName] (in the query critera), Which should link to a form called ChoosePark, with a combobox called ParkName but when I click on the Run Report button I either get a blank report or nothing happens, so I'm not sure how to get the command button to work, any ideas?


    I've almost got it now, only problem is the form won't auto close after the report is open...
    Last edited by RobRay; 10-28-2010 at 03:37 PM. Reason: update

  4. #4
    slave138's Avatar
    slave138 is offline Competent Performer
    Windows XP Access 2007
    Join Date
    Oct 2010
    Location
    WI
    Posts
    233
    If you want the form to close when the report loads you can try these to see if they work:

    Set the OnLoad event for your Report to:
    Code:
    DoCmd.Close acForm, "frmYourFormName", acSaveNo
    If that doesn't work you can try a timer by setting the OnTimer event of your form to the same code as above. Then use whatever event triggers the report to open from the form and add some code:
    Code:
    Me.Form.TimerInterval = x
    Where 'x' is the time in miliseconds (1000 = 1 sec).

  5. #5
    Join Date
    May 2010
    Posts
    339
    Quote Originally Posted by RobRay View Post


    I just want to choose from a drop down box and have the corresponding report appear with all of it's subreports referring to the same thing.

    How can I do this?

    Thanks!
    Is this what your trying to do? See sample.

  6. #6
    RobRay is offline Novice
    Windows XP Access 2003
    Join Date
    Oct 2010
    Posts
    11
    Thanks for the replys,

    Slave: I'm using 2003, as far as I can see there is no "on load" event, just "on open" and I tried that code there, but no dice...

    The second one I also couldn't get to work, although I did get an error telling me that Access can't find the macro DoCmd

    The event that triggers the report to open is a command button, and that is where I put the time.


    Access Blaster: Thanks, that's what I want, but I also want the form to close? Any more help on that front?

  7. #7
    Join Date
    May 2010
    Posts
    339

    Revised Sample

    Ok now it closes.

  8. #8
    RobRay is offline Novice
    Windows XP Access 2003
    Join Date
    Oct 2010
    Posts
    11
    Awesome, thanks Access Blaster, got mine working now

  9. #9
    slave138's Avatar
    slave138 is offline Competent Performer
    Windows XP Access 2007
    Join Date
    Oct 2010
    Location
    WI
    Posts
    233
    Sample worked great for me and I was able to swap in the code to have it close the form in the report's OnLoad event without any problems. If he is getting errors for DoCmd, I'd say there is something bigger causing a problem...

    UPDATE: Nevermind - looks like it's not a problem anymore.
    Last edited by slave138; 10-29-2010 at 11:04 AM. Reason: Update

  10. #10
    Join Date
    May 2010
    Posts
    339
    Quote Originally Posted by RobRay View Post
    Awesome, thanks Access Blaster, got mine working now
    Glad it worked out for you.


    Richard

  11. #11
    thbaig1 is offline Novice
    Windows XP Access 2003
    Join Date
    Nov 2010
    Posts
    2

    OLE error

    Quote Originally Posted by Access_Blaster View Post
    Ok now it closes.
    Hi Access_Blaster,
    I have followed your code instructions, but for my db , it is giviing some OLE ,OLX server error.
    Can you please help me out?

    I have attached the db file and placed form at startup.

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

Similar Threads

  1. Choose whether to display empty fields in a report
    By exoticdisease in forum Access
    Replies: 1
    Last Post: 08-18-2010, 09:12 AM
  2. Form/Combo box parameter issue.
    By Bmo in forum Forms
    Replies: 2
    Last Post: 05-06-2010, 03:41 AM
  3. Automatically choose which report?
    By Lockrin in forum Reports
    Replies: 2
    Last Post: 12-28-2009, 02:41 PM
  4. How do I choose multiple records for a report
    By admaldo in forum Reports
    Replies: 2
    Last Post: 03-03-2006, 06:02 AM
  5. Add combo box to parameter query
    By louisa14 in forum Queries
    Replies: 1
    Last Post: 12-10-2005, 08:38 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