How to reference value from a table

N

Nate

Hello all!

I am using an OnClick event, placed on a form, to email a snapshot of a
report version of the record referenced on the form to a distribution
group.

I have three tables in use on this form:

1 - Employees - contains employee names and the primary key, the
employee ID
2 - Leads - contains Lead names and the primary key, the Lead ID
3 - Dashboards - contains the bulk of the data for this specific form,
and references both employees and leads

I have the Employees linked to the dashboards table via combo box. The
combo box displays the name and ID of each employee. The control is
named "employee name". As the primary key for the employees table is
the employee ID, whenever I reference 'employee name' as a control, it
gives an output of the employee ID instead of their name.

For my email to the distribution group, I want the employee's name in
the subject line. The code I am using:
---
DoCmd.OpenReport stDocName, acViewPreview, , "number =" & number
DoCmd.SendObject acSendReport, stDocName, "Snapshot Format",
"Dashboard", , , "Dashboard Attached for Employee:" & employee_name,
"Attached, please find a dashboard for Employee: " & employee_name
DoCmd.Close
---

leaves me with only an employee ID (the primary key of the field.) Is
there any way I can reference the other part of that record (the
employee name)?

Thanks in advance!
 
M

Marshall Barton

Nate said:
I am using an OnClick event, placed on a form, to email a snapshot of a
report version of the record referenced on the form to a distribution
group.

I have three tables in use on this form:

1 - Employees - contains employee names and the primary key, the
employee ID
2 - Leads - contains Lead names and the primary key, the Lead ID
3 - Dashboards - contains the bulk of the data for this specific form,
and references both employees and leads

I have the Employees linked to the dashboards table via combo box. The
combo box displays the name and ID of each employee. The control is
named "employee name". As the primary key for the employees table is
the employee ID, whenever I reference 'employee name' as a control, it
gives an output of the employee ID instead of their name.

For my email to the distribution group, I want the employee's name in
the subject line. The code I am using:
---
DoCmd.OpenReport stDocName, acViewPreview, , "number =" & number
DoCmd.SendObject acSendReport, stDocName, "Snapshot Format",
"Dashboard", , , "Dashboard Attached for Employee:" & employee_name,
"Attached, please find a dashboard for Employee: " & employee_name
DoCmd.Close
---

leaves me with only an employee ID (the primary key of the field.) Is
there any way I can reference the other part of that record (the
employee name)?


If the combo box's second column is the name, then use
employee_name.Column(1)
 

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