Combining multiple fields to populate a combo box with different formats (1 Viewer)

spet

Registered User.
Local time
Yesterday, 18:21
Joined
Oct 5, 2018
Messages
38
Hello and thank you all in advance for your help.


I'm currently adding two fields together in a query to populate a combo box that then in return passes those values to a report.


My first field: empID

My second field: empName


empID consists of
1.0

1.1
21.0
100.10


empName consists of
John
Mary
Sue
Paul


I'm combining then in the query as a single field Emp: [emp ID] & " - " & Trim([empName])


Resulting in

1.0 - John
1.1 - Mary
21.0 - Sue
100.10 - Paul


I now want to pass only the empID to a report I'm calling from this form, but I'm not quite sure how to do that with the left function as they are different values.


I hope this makes sense. I'm very new to this community and Access.
 

plog

Banishment Pending
Local time
Yesterday, 18:21
Joined
May 11, 2011
Messages
11,645
Normally things don't get "passed" to the report from a form. There's 2 ways that its typically done:

1. Use the control on the form to filter a query which the report is based on. So the query gets data from the form, it gets filtered to just that data and then the report opens using that query as its datasource

2. Open the report via a DoCmd.OpenReport (https://docs.microsoft.com/en-us/office/vba/api/access.docmd.openreport) call from code on the form. You click a button on the form, it looks at the form and opens the report using the data you want to filter the report.

In either case, when working with combo boxes you can show one field to the user and use another field within the database itself. Check out this link for that:

https://www.techonthenet.com/access/comboboxes/bind_index.php
 

spet

Registered User.
Local time
Yesterday, 18:21
Joined
Oct 5, 2018
Messages
38
Thank you so very much! Much easier to accomplish what I want to do than what I was trying.
 

Users who are viewing this thread

Top Bottom