Need help creating a report from an open record on a form?

  • Thread starter Thread starter TTK
  • Start date Start date
T

TTK

Guest
Hi. I've been struggling with a report problem. I've created a form based on a table. From here I open a second form based on the same table - this second form is set up such that it opens the same record that I had open in the first form. I then Have a report set to print that should print the same records as the open form. I have the report running off of a query - not the same table as the open form. I cannot figure out how to make the query and the associated report "Know" which records to pull based on which record is currently open in the form. Can anyone help? I would greatly appreciate any assistance!

-Tracy
 
First make a query that holds all the fields that you want displayed within the report. Make sure that one of the fields contains a common ID such as CustomerID.

Next make a command button on the form and set the event procedure for On Click, that would be the following:

Private Sub CommandButtonName_Click()
On Error GoTo CommandButtonName_Click_Err

DoCmd.OpenReport "ReportName", acNormal, "", "[CustomerID]=[Forms]![MainFormName]![SubFormName]![CustomerID]"


CommandButtonName_Click_Exit:
Exit Sub

CommandButtonName_Click_Err:
MsgBox Error$
Resume CommandButtonName_Click_Exit

End Sub

Change the names accordingly to what they actually are.

Good luck.
 

Users who are viewing this thread

Back
Top Bottom