Hi, Garry.
I have a from that I would like to add a command button to that will print
only the current record. Is this possible & how do I do it?
Forms aren't really meant for printing. That's what reports are for. But
yes, it's possible if you have Access 2003. It may work on Access 2000 and
2002, but I don't think it works on Access 97 and earlier versions.
If your form is displaying a record of a table with a primary key, then try:
Private Sub PrtRecBtn_Click()
On Error GoTo ErrHandler
DoCmd.OpenForm Me.Name, , , "ID = " & Me!txtID.Value
DoCmd.OpenForm Me.Name, acPreview
DoCmd.PrintOut acSelection
Exit Sub
ErrHandler:
MsgBox "Error in PrtRecBtn_Click( )." & vbCrLf & vbCrLf & _
"Error #" & Err.Number & vbCrLf & vbCrLf & Err.Description
Err.Clear
End Sub
.... where txtID is the name of the text box displaying the primary key and
ID is the primary key.
HTH.
Gunny
See
http://www.QBuilt.com for all your database needs.
See
http://www.Access.QBuilt.com for Microsoft Access tips.
(Please remove ZERO_SPAM from my reply E-mail address so that a message will
be forwarded to me.)
- - -
If my answer has helped you, please sign in and answer yes to the question
"Did this post answer your question?" at the bottom of the message, which
adds your question and the answers to the database of answers. Remember that
questions answered the quickest are often from those who have a history of
rewarding the contributors who have taken the time to answer questions
correctly.