Report for just one record

  • Thread starter Thread starter Lindsay
  • Start date Start date
L

Lindsay

I am creating a database to create and store purchase orders. I
created my form to input the information and my purchase order
(report). But everytime I create a new purchase order it just gets
added to the original report and I see all the purchase orders instead
of just the one that I created most recently. Could anyone offer any
advice for this situation. I just want to see one purchase order at
time.
 
I have posted the answer to this type of question many times recently. Did
you try searching for your answer before posting a new thread?

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
 
Back
Top