I did something wrong and I can't figure out what it is.
I created a print form button on a form (Access 2003).
I was careful to use the "print current form" selection.
After I fill in the form and click the print command button, Access
prints a form for every record and not just the current record for the
form I just filled in.
Anyone have any idea what I did?
You should print reports, not forms. To include a button that prints a
report showing only the current record, you can use the following code...
Button to print specific record
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 = "[ID] = " & Me.[ID]
DoCmd.OpenReport "MyReport", acViewPreview, , strWhere
End If
End Sub
Notes: If your primary key is a Text type field (not a Number type field),
you need extra quotes: strWhere = "[ID] = """ & Me.[ID] & """"
If you want the report to print without preview, replace acViewPreview with
acViewNormal.
See also: http://allenbrowne.com/casu-15.html
See also: http://www.databasedev.co.uk/print_form_record.html

Signature
Hope that helps!
RBear3
.
> I did something wrong and I can't figure out what it is.
>
[quoted text clipped - 7 lines]
>
> Anyone have any idea what I did?