Results 1 to 4 of 4
  1. #1
    Join Date
    May 2004
    Posts
    37

    Unanswered: Define Query Criteria Parameter Value from a List Box

    Hi,

    I have a query with the following values in it:

    Item ID
    Item Text
    Possible Answers
    Correct Answer
    Item Classification



    Under Item Classification, I have the following criteria:

    Code:
    [Forms]![frmForm1]![Item Classification]

    Here's what I want to do:

    I have a list box on the form that lists all of the Item Classifications currently in the database. When the user clicks a certain Item Classification, I want a report (rptReport1) to open and display only the records that have the selected Item Classification.

    So my question is....How can I have the list box automatically fill in the parameter value for the criteria with the user's selection?

    Thank you

  2. #2
    Join Date
    Feb 2004
    Location
    Chicago, IL
    Posts
    1,312
    One way to do it, is to base rptReport1 on all of the classifications in the database. Then when you open the report with a DoCmd.OpenReport you can filter the report on the [Forms]![frmForm1]![Item Classification] field.

    Assuming Item Classification is a string:

    If [Forms]![frmForm1]![Item Classification] & ""<>"" then
    docmd.OpenReport "rptReport1",,,"[Item Classification]='" & [Forms]![frmForm1]![Item Classification] & "'"
    end if

    Make sure the Report has filtering turned on. In the Data tab of the Report properties, Filter On.

  3. #3
    Join Date
    May 2004
    Posts
    37
    Thanks!

    One question. How can I open the report in preview mode instead of printing it automatically?

    Thanks again

  4. #4
    Join Date
    Feb 2004
    Location
    Chicago, IL
    Posts
    1,312
    Like this:

    docmd.OpenReport "rptReport1",acViewPreview,,"[Item Classification]='" & [Forms]![frmForm1]![Item Classification] & "'"

    It's the added 'acViewPreview' that will print it to screen first.

Posting Permissions

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