Open A report from Form

chrisguk

Registered User.
Local time
Today, 07:23
Joined
Mar 9, 2011
Messages
148
I have a subform like so:

Main Form = frmSitesLog
Subform = frmSitesLogSavings
The subform has multiple calulation fields within it that will be transferred to a report.

The name of my report is rtpSitesLogSavings

The form is controlled by control name SavingsID and so is the report.

I am trying to select a cmd button from the frmSitesLogSavings to open a report with the corresponding record displayed. I am trying to get the following code to work correctly.

Code:
DoCmd.OpenReport stDocName, acPreview, , [savingsid] = " & savingsid"

Any ideas?
 
Send a short example of your MDB, (access 2000 or 2002-2003).
 
Send a short example of your MDB, (access 2000 or 2002-2003).

This is what the command btn vba looks like:

Code:
Private Sub BtnPrintSavings_Report_Click()
On Error GoTo Err_BtnPrintSavings_Report_Click
    Dim stDocName As String
    stDocName = "rptSitesLogSavings"
    DoCmd.OpenReport stDocName, acPreview, , [savingsid] = " & me.savingsid"
    
Exit_BtnPrintSavings_Report_Click:
    Exit Sub
Err_BtnPrintSavings_Report_Click:
    MsgBox err.Description
    Resume Exit_BtnPrintSavings_Report_Click
    
End Sub
 
Send a short example with some records in the MainForm, and some records in
the Subform, and a Report.
 
You made the parameter a string, it should be:
Code:
DoCmd.OpenReport stDocName, acPreview, , [COLOR="Red"]"[/COLOR][savingsid] = " & me.savingsid
 

Users who are viewing this thread

Back
Top Bottom