Putting current data in a report

Robert C

Registered User.
Local time
Today, 10:34
Joined
Mar 27, 2000
Messages
88
I have a form - DealersMain - on which I have a subform - Contacts. Currently I have a button on the form which enables me to print an envolope containing the DealerrName, DealerAddress, etc of the record currently being viewed.

What I would like to achieve is for the envelope to show, not only the current SupplierName etc but also the current ContactName as displayed on the subform. At the moment the envelope shows the first ContactName, not the one which is actually current on the form/subform. Each dealer can have up to four or five contact names. The Record Source for the envolope report is a query called qryDealerEnvelope.

The code I am using at the moment is:-

Private Sub btnPrintDealerEnv_Click()
On Error GoTo Err_btnPrintDealerEnv_Click

Dim stDocName As String

stDocName = "rptDealerEnvelope"
DoCmd.OpenReport stDocName, acViewPreview, , "[DealerID]=forms!frmDealersMain![DealerID]"

Exit_btnPrintDealerEnv_Click:
Exit Sub

Err_btnPrintDealerEnv_Click:
MsgBox Err.Description
Resume Exit_btnPrintDealerEnv_Click

End Sub

Any help would be greatly appreciated.
 
Try...
DoCmd.OpenReport stDocName, acViewPreview, , "[DealerID]=forms!frmDealersMain![DealerID] And [ContactID]=forms!frmDealersMain![subformname]![ContactID]"


HTH

Kevin M
 

Users who are viewing this thread

Back
Top Bottom