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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Print a form 1

Status
Not open for further replies.

austen

Technical User
Nov 12, 2008
14
GB
Hi there,

I have a Form. On this Form I have a button that allows the user to print the current Form they are viewing but for some reason they always seem to print all the records not just the one. The button/command is a Macro (PrintOut.(Print selected copies = 1))
Can anyone tell me what I am doing wrong please? It always seems to work when I do it…

A…
Hi there,

I have a Form. On this Form I have a button that allows the user to print the current Form they are viewing but for some reason they always seem to print all the records not just the one. The button/command is a Macro (PrintOut.(Print selected copies = 1))
Can anyone tell me what I am doing wrong please? It always seems to work when I do it…

A…
 

Forms are not really designed to be printed.
I'd suggest you create a report.
If you're getting all records, it probably means you haven't included a WHERE clause.


Randy
 
If you want to print only the current record, you could do this:
Code:
Private Sub PrintForm_Click()
    Dim myID As Long
    
    myID = [ID] ' Unique identifier for a record
    
    ' Activate filter on the current record.
    Me.Filter = "([Table1].[ID]=" & myID & ")"
    Me.FilterOn = True
    
    ' Print only the current record.
    DoCmd.PrintOut acPages
    
    ' Deactivate the filter.
    Me.Filter = ""
    Me.FilterOn = False
    
    ' Return to the current record.
    Me.RecordsetClone.FindFirst "[ID]=" & myID
    If Not Me.RecordsetClone.NoMatch Then
        Me.Bookmark = Me.RecordsetClone.Bookmark
    End If
End Sub

Regards,
Lisa
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top