Report on current record

D

Daniel

Hi Guys.

I'm trying to run a report on the currently viewed record in my form.

This is the VBA that I'm currently using


Private Sub Command211_Click()
DoCmd.OpenReport "Fax Reminder Form", acViewPreview, , _
"[EmployeeIdentifier]=Forms!frmEmployee_Details_Form![EmployeeIdentifier]"

End Sub
Fax Reminder Form is the name of my report
EmployeeIdentifier is the unique field used to identify the record

For some reason using the code brings up the very first record in my table.

Here is my SQL if that helps


SELECT [Employee Details].FirstName, [Employee Details].Surname, [School
Details].Principal, [Employee Details].EmployeeIdentifier
FROM [Employee Details], [School Details];
 
A

Allen Browne

Concatenate the value from the form into the WhereCondition string:
"[EmployeeIdentifier] = " &
Forms!frmEmployee_Details_Form![EmployeeIdentifier]

More info on ensuring the record is saved, there is a record, and the data
types are correct here:
Print the record in the form
at:
http://allenbrowne.com/casu-15.html
 

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