Using List/Combo Box to Obtain Parameter Information

J

JWeaver

I want to be able to print reports that contain only 1 employee's
information. I have set up a query with a parameter to pull this information
and it works but is there a way to set it up so that there is a list box or
combo box to choose the employee's name from instead of having to type it
each time? Using a list would prevent names from being spelled incorrectly.

Any help you can give me would be appreciated!
 
K

Klatuu

In this case, the Combo box would be the preferred way to do it.
Create a combo that has two columns, the unique employee id (should ususally
be the primary key field for the employee table), and the employee name.

Now, here is the good part. You can use the combo to filter your report.
Don't put any filtering by employee in the report's record source query, do
it in the OpenReport method. If the combo is set up as suggested, the combo
will return the primary key value for the selected employee. You then use
that in the Where arguement of the OpenReport method:

Dim strWhere As String

strWhere = "[EmployeeID] = " & Me.cboEmployee
DoCmd.OpenReport "rptEmpReport", , , strWhere
 
T

Tellu

I have the same problem. I´d like to ask where should I put the Combo box?
This seems to be a little bit difficult for me...
--
Thanks a lot!

Tellu


"Klatuu" kirjoitti:
In this case, the Combo box would be the preferred way to do it.
Create a combo that has two columns, the unique employee id (should ususally
be the primary key field for the employee table), and the employee name.

Now, here is the good part. You can use the combo to filter your report.
Don't put any filtering by employee in the report's record source query, do
it in the OpenReport method. If the combo is set up as suggested, the combo
will return the primary key value for the selected employee. You then use
that in the Where arguement of the OpenReport method:

Dim strWhere As String

strWhere = "[EmployeeID] = " & Me.cboEmployee
DoCmd.OpenReport "rptEmpReport", , , strWhere
--
Dave Hargis, Microsoft Access MVP


JWeaver said:
I want to be able to print reports that contain only 1 employee's
information. I have set up a query with a parameter to pull this information
and it works but is there a way to set it up so that there is a list box or
combo box to choose the employee's name from instead of having to type it
each time? Using a list would prevent names from being spelled incorrectly.

Any help you can give me would be appreciated!
 
K

Klatuu

The combo box should go on a form with the command button. First you select
an employee then click the command button to run the report.
--
Dave Hargis, Microsoft Access MVP


Tellu said:
I have the same problem. I´d like to ask where should I put the Combo box?
This seems to be a little bit difficult for me...
--
Thanks a lot!

Tellu


"Klatuu" kirjoitti:
In this case, the Combo box would be the preferred way to do it.
Create a combo that has two columns, the unique employee id (should ususally
be the primary key field for the employee table), and the employee name.

Now, here is the good part. You can use the combo to filter your report.
Don't put any filtering by employee in the report's record source query, do
it in the OpenReport method. If the combo is set up as suggested, the combo
will return the primary key value for the selected employee. You then use
that in the Where arguement of the OpenReport method:

Dim strWhere As String

strWhere = "[EmployeeID] = " & Me.cboEmployee
DoCmd.OpenReport "rptEmpReport", , , strWhere
--
Dave Hargis, Microsoft Access MVP


JWeaver said:
I want to be able to print reports that contain only 1 employee's
information. I have set up a query with a parameter to pull this information
and it works but is there a way to set it up so that there is a list box or
combo box to choose the employee's name from instead of having to type it
each time? Using a list would prevent names from being spelled incorrectly.

Any help you can give me would be appreciated!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top