G
Guest
Hi all,
I wanted to add a "print form" button to a form. Basically, instead of
using a report based on the form, I just wanted to be able to print the form.
To that end, I added the following code to the click event of a command
button:
_________________
If Me.NewRecord Then
MsgBox ("You cannot print a blank record!")
Exit Sub
End If
DoCmd.ApplyFilter , "ID = " & Me.ID
DoCmd.PrintOut
Me.FilterOn = False
Me.Requery
End Sub
________________
Because I display the Access navigation buttons on my form, I had to filter
the form or it would print all the records out. I'd guess that one of the
benefits of making your own navigation buttons is that possibly that wouldn't
be neccessary, but I don't know and it doesn't matter here.
Two questions:
1. Is using that Me.FilterOn = False give me the same results as if I hit
the 'Remove Filter' button on the Filter/Sort toolbar?
2. When the form requeries, it puts the current record (the one that
printed) as the first record in the recordset such that it's 1 of x records
down by the navigation buttons. That seems a bit confusing for a user that
may be using the navigation buttons to scroll between a few records....after
the print the records have lost their relative location (or at least that one
has).
Is there a way to requery the form such that the default order is restored
and the printed record is the current record after the requery (read, instead
of being record 1 of x where x is the total, the record would be y of x where
y is the records previous relative location before the form was filtered by
the vba code)?
Tahnks for any feedback,
CW
I wanted to add a "print form" button to a form. Basically, instead of
using a report based on the form, I just wanted to be able to print the form.
To that end, I added the following code to the click event of a command
button:
_________________
If Me.NewRecord Then
MsgBox ("You cannot print a blank record!")
Exit Sub
End If
DoCmd.ApplyFilter , "ID = " & Me.ID
DoCmd.PrintOut
Me.FilterOn = False
Me.Requery
End Sub
________________
Because I display the Access navigation buttons on my form, I had to filter
the form or it would print all the records out. I'd guess that one of the
benefits of making your own navigation buttons is that possibly that wouldn't
be neccessary, but I don't know and it doesn't matter here.
Two questions:
1. Is using that Me.FilterOn = False give me the same results as if I hit
the 'Remove Filter' button on the Filter/Sort toolbar?
2. When the form requeries, it puts the current record (the one that
printed) as the first record in the recordset such that it's 1 of x records
down by the navigation buttons. That seems a bit confusing for a user that
may be using the navigation buttons to scroll between a few records....after
the print the records have lost their relative location (or at least that one
has).
Is there a way to requery the form such that the default order is restored
and the printed record is the current record after the requery (read, instead
of being record 1 of x where x is the total, the record would be y of x where
y is the records previous relative location before the form was filtered by
the vba code)?
Tahnks for any feedback,
CW