Question printing a form (1 Viewer)

britesynth

Registered User.
Local time
Today, 11:33
Joined
Mar 11, 2013
Messages
88
how do I go about printing specific records displayed in a form? I basically just want to add a print button on my form to do this

i have a main form with a button that displays/opens a form

i then want to print the records displayed in the opened form

(please see attached pictures)

thanks in advance!
 

Attachments

  • pics.zip
    100.8 KB · Views: 79

burrina

Registered User.
Local time
Yesterday, 22:33
Joined
May 10, 2014
Messages
972
Why? It can be done but why not a a Report?


PHP:
'Print Single Record on Form.
Dim myForm As Form
Dim PageNo As Integer
 
PageNo = Me.CurrentRecord
Set myForm = Screen.ActiveForm
 
DoCmd.SelectObject acForm, myForm.Name, True
DoCmd.PrintOut acPages, PageNo , PageNo , , 1
DoCmd.SelectObject acForm, myForm.Name, False


DoCmd.RunCommand acCmdSizeToFitForm
 

AccessBlaster

Registered User.
Local time
Yesterday, 20:33
Joined
May 22, 2010
Messages
5,913
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 = "[[I]ID[/I]] = " & Me.[[I]ID[/I]]
        DoCmd.OpenReport "[I]MyReport[/I]", acViewPreview, , strWhere
    End If
End Sub
 

JLCantara

Registered User.
Local time
Yesterday, 20:33
Joined
Jul 22, 2012
Messages
335
This method will always work report open or not:
Code:
     DoCmd.OpenReport "ReportName", acViewPreview, , , acHidden
        Reports!ReportName.Filter = "RecordID = " & RecordID
        Reports!ReportName.FilterOn = True
    DoCmd.OpenReport "ReportName", acViewPreview

Good luck, JLC.
 

Users who are viewing this thread

Top Bottom