Criteria Command linked to one selection from a listbox in a form

BWG3

Registered User.
Local time
Today, 06:31
Joined
Sep 22, 2009
Messages
44
I have a query with a column for Employees. I set up a criteria command that prompts the user to enter an employee ID number (The number is the Primary key ID number linked to each Employee in the "Employee" table). So as of right now, the user clicks on the report button which displays a prompt window which asks the user to enter in the employee ID number. EX. The user will enter "1" to see all Bill's hours worked, "2" to see Sarah's hours worked, and so on.

I want to set up a form that will contain a listbox that will allow the user to select an employee's name instead of having to know what number corresponds to each employee. So if I select "Bill" in the list box and click "OK" (this command button will be linked to the report which is based on the query), a number "1" will automatically be placed in the Criteria, and the report open just displaying Bill's hours. I want to do this to eliminate the prompt window so all the user has to do is select the name and the corresponding employee ID number is automatically placed in the criteria. Is there any command code I can place in the criteria command box to do this? I've tried [Forms]![FormName]![FieldName], but this does not work. Thanks in advance.
 
Forms!formname.fieldname refers to the field in the current record or a control by that name. If this is an unbound textbox with the name of the employee it won't work because its value will be the name instead of the ID.

Use a combobox as your selection. The bound field is set as the ID and the columns are the ID and the Name. Make the name the displayed column by setting the ID column width to zero. Refer to the combobox name in the SQL.
 
I'm not sure what you mean by refer to combo box is the SQL. I'm all new to this. If you mean to look at the SQL view of the query, I would not know the code needed to refer the the combo box.
 

Users who are viewing this thread

Back
Top Bottom