Results 1 to 5 of 5
  1. #1
    Join Date
    Aug 2004
    Posts
    364

    Unanswered: Help! Combobox and Listbox to Open Reports

    I have several Reports and Charts in Access 2002.

    I want a combo box on a form to allow me to select either "Reports" or "Charts" and display their titles in a listbox eg -

    If Reports are selected from the combo box the list box will show -

    1 - view report of names - click opens up the report
    2 - view report of age - click opens up the report
    etc etc

    If Charts are selected from the combo box the list box will show -

    1 - view chart of names - click opens up the chart
    2 - view chart of age - click opens up the chart.

    Any ideas on how to do this? Is it a query?

    Tom

  2. #2
    Join Date
    Oct 2004
    Posts
    8
    hi,

    change the "rowsource type" of your second combo box to table/query, then in the afterupdate event of your first combobox put:
    Code:
    if combo1="Reports" then
      combo2.rowsource="SELECT msysobjects.Name FROM msysobjects WHERE
                                      (((msysobjects.Type)=-32764));"
    else
      combo2.rowsource="SELECT msysobjects.Name FROM msysobjects WHERE
                                      (((msysobjects.Type)=?????));"
    end if
    i'm not sure of the value for chart objects, but if you go tools->options->view and check the box "System oBjects", look through the table "msysobjects" for the name of a chart, and then lookat the value of type.

    Code:
    stDocName = combo2
    DoCmd.OpenReport stDocName, acPreview
    this will work for the report, but not sure about opening a chart

    hth
    Last edited by n00bl0rd; 10-09-04 at 03:10.

  3. #3
    Join Date
    Aug 2004
    Posts
    364
    Thanks for your reply, I will give it a go.

    One note, I only have one combobox and one listbox, not 2 comboboxes.

    The combobox selectes either reports or charts and the list box displays the reports or charts names and can be clicked on to open them.

  4. #4
    Join Date
    Sep 2004
    Location
    Kuala Lumpur
    Posts
    60
    i think just change all of the 'combo2' names in the code above to list1 (the name of your list control). (i assume your combo box is set up? you might put the choices (Report and Chart) into a new table).
    w
    Last edited by wazz; 10-09-04 at 12:29.

  5. #5
    Join Date
    Aug 2004
    Posts
    364
    Yeah ive got a new table, the thing is the value for chart objects appears to be the same as for reports - 32764. Is this the case because I need the list box to show either reports or charts depending on what the combo box is displaying.

    Also, the list box will show the names of the reports or charts, but the names arent very 'user friendly'...is there a way of displaying a better title for reports or charts? For example a report may be displayed as "rprt_choose_age" in the list box, but I could do with it saying "Select Age". I cant go and rename anything though!!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •