Print Current Record to Report

Ukraine82

Registered User.
Local time
Today, 08:14
Joined
Jun 14, 2004
Messages
346
I'm having hard trouble doing print preview current record from form with subform to a report.

When using the code below I'm getting an error for:

The specified field [PolicyNum] could refer to more than 1 table listed in the from clause of your sql statement.

Dim strDocName As String
Dim strLinkCriteria As String

strDocName = "rptCurrentInfo"
strLinkCriteria = "[PolicyNum] = Forms![frmAdjusterMod]![PolicyNum]"

DoCmd.OpenReport strDocName, acViewPreview, , strLinkCriteria


Command button is in the main form frmadjustermod - sbfm is sbfmMoreMod

foreign key is PolicyNum

Thanks,
Michael
 
I believe in the SQL of your report you need to define which table the PolicyNum is coming from. Like this...

TableA.PolicyNum

instead of just

PolicyNum
 
ghudson said:
I believe in the SQL of your report you need to define which table the PolicyNum is coming from. Like this...

TableA.PolicyNum

instead of just

PolicyNum

ghudson,

Thanks I really appreciated

Michael
 
This is really worked.


Syntax:
DoCmd.OpenReport "REPORT NAME", acViewPreview, , "[PRIMARY KEY] = " & Me.PRIMARY_KEY


Uses:
DoCmd.OpenReport "Purchase Order", acViewPreview, , "[Order Number]=" & Me.Order_Number
 
http://allenbrowne.com/casu-15.html

Code:
Private Sub cmdPrint_Click()
    Dim strWhere As String

    If Me.Dirty Then    'Save any edits.
        Me.Dirty = False
    End If

    If Me.NewRecord Then 'Check there is a record to print
        MsgBox "Select a record to print"
    Else
        strWhere = "[ID] = " & Me.[ID]
        DoCmd.OpenReport "MyReport", acViewPreview, , strWhere
    End If
End Sub
 
Very, very old post ressurrected by a poster who also replied to two other old posts.?
 

Users who are viewing this thread

Back
Top Bottom