Create Report from filtered records in a form (1 Viewer)

mtagliaferri

Registered User.
Local time
Today, 05:47
Joined
Jul 16, 2006
Messages
519
I need to create a report from a form, this form have some filter buttons, therefore I need to print what is actually shown on the screen, how can achieve this?:confused:
my filter code is
Code:
Private Sub CmdViewActive_Click()
DoCmd.BrowseTo acForm, "frmCrewMemberList", "", "[Resigned] = False", "", 1
End Sub
which will display only those records which have the resigned box empty.
the print code is:
Code:
Private Sub cmdPrint_Click()

    DoCmd.OpenReport "rptCrewMemberList", acViewPreview, "", "", acNormal
    DoCmd.RunCommand acCmdPrint

End Sub
Thanks
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 12:47
Joined
May 7, 2009
Messages
19,247
DoCmd.OpenReport "rptCrewMemberList", acViewPreview, "", "[Resigned]=False", acNormal
 

mtagliaferri

Registered User.
Local time
Today, 05:47
Joined
Jul 16, 2006
Messages
519
Thanks arnel.p, that would limit the report to the filter in the VBA command, my problem is that on the form I have 3 button which filter the records: all, resigned and active. I only have one print btn which will need to open or print the report According to the filter that has been applied from the user on the form. Hope this makes sense!
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 12:47
Joined
May 7, 2009
Messages
19,247
is that so, ok, then use your form's filter:

Private Sub cmdPrint_Click()

dim strFilter As String

If Me.FilterOn Then strFilter=Me.Filter

DoCmd.OpenReport "rptCrewMemberList", acViewPreview, "", strFilter, acNormal
DoCmd.RunCommand acCmdPrint

End Sub
 

mtagliaferri

Registered User.
Local time
Today, 05:47
Joined
Jul 16, 2006
Messages
519
Thanks arnelgp!!! that solved the problem !!!
Just to put the cherry on the cake...the records displayed on the form are sorted by Staff Number in ascending order but the print option are in different order which I presume to be the primary Key ascending order, how can I order the print out by staff number ascending?
 

Users who are viewing this thread

Top Bottom