Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Print current record only

Status
Not open for further replies.

jazminecat23

Programmer
Mar 16, 2007
103
US
Hi all - I have a form with a simple print button on it. I want the button to open my report only with the current record. here's my code:

Code:
Private Sub PrintRecord_Click()
On Error GoTo Err_PrintRecord_Click

    Dim stDocName As String

    stDocName = "VendorRequestReport"
    DoCmd.OpenReport stDocName, acViewPreview, , "VENDOR_NUM=" & Me.VENDOR_NUM
    
Exit_PrintRecord_Click:
    Exit Sub

Err_PrintRecord_Click:
    MsgBox Err.Description
    Resume Exit_PrintRecord_Click
    
End Sub

Can anyone see what I might be missing? VENDOR_NUM is a textbox, and the form is set to view a single record at a time. Thanks in advance for your help!
 
Vendor num may be stored as a string; if so, this should work:
DoCmd.OpenReport stDocName, acViewPreview, , "VENDOR_NUM = '" & Me.VENDOR_NUM & "'"

I wondered why the baseball was getting bigger.
Then it hit me.
 
Hi - thanks for the reply, but it still loads the report with all records, not just the current record. If it matters, the vendor num is stored as int, and this is an adp.
 
Try...
Code:
DoCmd.OpenReport stDocName, acViewPreview, , "[VENDOR_NUM]=" & [b]Forms![/b][your form name].VENDOR_NUM
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top