Discussion Locked

Access 2000 Report Question

0 helpful
5 replies
Closed to new repliesThis discussion is closed. It stays readable, but it takes no new replies.

I am using Access 2000. I have created a report in access that lists all employees and is sorted by department. This report is based on a query that uses [] for department name and prompts the user to enter in the department for the appropriate report.

What I would like to do is create a form that contains a combo-box that lists all the departments, and a button that will print out the department report based on what department the user selected from the combo box.
I have got everything set except for the code for the button. Help!!

5 replies

by richtee

An altenate way to accomplish what you want would be to use the criteria field of the query directly.

This works easiest with a List Box on your form.

In the criteria field of the department name, instead of [], make this value the value of the list box on your form. This can easily be done by right-clicking the criteria field, select build, select the form, select the control.

No additional code would be needed.

Hope this helps you. Rich

by richtee

Clarification of no additional code needed for the selection of the department -- but one line of code is needed in the 'After Update" event of the list box. Just enter: Requery

by donq

Create a query that lists Department Names (only) and after testing it save it as "qcDeptName" (meaning Combo-box query for Department Names). Open the query in SQL View and copy (Ctrl + C) it to the clipboard.

Build a new unattached form named "GetDeptName" and place an unattached Combo box on it namen "DeptName". Open the Combo box and paste (Ctrl + V) the clipboard contents into the combo boxes Row Source property and set Limit to List to Yes.

Then place a button on GetDeptName that calls your report based on your original query AND place [GetDeptName].[DeptName] in the "Criteria:" slot in your original report query under Department (or whatever column name contains your department names) so the users selection becomes your reports Department filter.

Now on your original button that called the report change it to open GetDeptName.

This works nicely and you will use it often once you get the process comitted to memory.

This discussion is closed to new replies.