First you set up the query that you want to view with the following criterion for the field(s) that you want users to be able to select (substituting the actual names of your form and combo box):
[tt][Forms]![frm_QryView]![cboFieldChoice][/tt]
The combo box has its RowSource set to the field of the table from which you want to select. Use the wizard to create the box and only choose to show the field with the parameter entry.
**Understand that you'll visually refer to the [tt]LastName[/tt] etc., field in the combo (it will be in column #2) but Access will refer to the key of that table (in column #1 with the width set by the wizard to "0";", so that it's not visible in the dropdown list). For this reason make sure that the field in the query is the key/id field of that table, not the [tt]LastName[/tt], etc. field.
The next step is to create a dedicated parameter form. Just a small form with its popup property set to true and your combo on it. Place a button on the form that has the following in the MyButton_Click() event:
To deal with user failure to select a value you could have the [tt] button.enabled [/tt] property set to False and the reset to True by the combo_Click() event. To allow the option of return of all values if the user selects none go back to the query and in the "OR" parameter line below the first parameter entry just put the exact parameter prompt with "Is Null" after it, e.g., [Enter the Last Name] Is Null.
You can have the button open a report based on the query just as easily. Create the report based on the query and change the DoCmd line to DoCmd.OpenReport "myParaReport".
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.