Print result of combo box selection on form

G

Guest

I have a combo box on my form with the row source as: SELECT
tblEmployees.lngEmployeeID, tblEmployees.strFirstName FROM tblEmployees; to
choose which employee creates a new invoice. After the form is "Continued"
(which updates the inventory table, customer table, etc.) it will print the
Invoice. I would like to print the employee name on the report, but so far
can only get it to print the Employee number. The feild on the report has
the control source of =[Forms]![frmInvoices]![EmployeeID].
Do I need an IIf statement or is there some way to pull the result of the
coice in the combo box?
Thanks!
 
F

fredg

I have a combo box on my form with the row source as: SELECT
tblEmployees.lngEmployeeID, tblEmployees.strFirstName FROM tblEmployees; to
choose which employee creates a new invoice. After the form is "Continued"
(which updates the inventory table, customer table, etc.) it will print the
Invoice. I would like to print the employee name on the report, but so far
can only get it to print the Employee number. The feild on the report has
the control source of =[Forms]![frmInvoices]![EmployeeID].
Do I need an IIf statement or is there some way to pull the result of the
coice in the combo box?
Thanks!

Is the combo box name "EmployeeID"?

=[Forms]![frmInvoices]![EmployeeID].Column(1)

To show a column other than the bound column, you must specify which
one. Combo boxes are are Zero based, so column(1) is the second
column. The above will display the First Name of the employee.
The form must be open when the report is run.
 
M

Marshall Barton

Scheetz said:
I have a combo box on my form with the row source as: SELECT
tblEmployees.lngEmployeeID, tblEmployees.strFirstName FROM tblEmployees; to
choose which employee creates a new invoice. After the form is "Continued"
(which updates the inventory table, customer table, etc.) it will print the
Invoice. I would like to print the employee name on the report, but so far
can only get it to print the Employee number. The feild on the report has
the control source of =[Forms]![frmInvoices]![EmployeeID].
Do I need an IIf statement or is there some way to pull the result of the
coice in the combo box?


As long as the form is still open (and assuming EmployeeID
is the name of the combo box), you can use:

=[Forms]![frmInvoices]![EmployeeID].Column(1)

If the form is closed, you could use several techniques.
The simplest is probably:

=DLookup("strFirstname", "tblEmployees", "lngEmployeeID="
& Forms!frmInvoices!EmployeeID)
 
G

Guest

Thanks to you both. I used one for when the form is open a we print and the
other for our "reprint" button. Both work fine.

Marshall Barton said:
Scheetz said:
I have a combo box on my form with the row source as: SELECT
tblEmployees.lngEmployeeID, tblEmployees.strFirstName FROM tblEmployees; to
choose which employee creates a new invoice. After the form is "Continued"
(which updates the inventory table, customer table, etc.) it will print the
Invoice. I would like to print the employee name on the report, but so far
can only get it to print the Employee number. The feild on the report has
the control source of =[Forms]![frmInvoices]![EmployeeID].
Do I need an IIf statement or is there some way to pull the result of the
coice in the combo box?


As long as the form is still open (and assuming EmployeeID
is the name of the combo box), you can use:

=[Forms]![frmInvoices]![EmployeeID].Column(1)

If the form is closed, you could use several techniques.
The simplest is probably:

=DLookup("strFirstname", "tblEmployees", "lngEmployeeID="
& Forms!frmInvoices!EmployeeID)
 

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