Report from a form

  • Thread starter Thread starter Bhavin
  • Start date Start date
B

Bhavin

I have managed to create a report using the wizard from a
form. However, the report lists all entrie in the table
that the form is linked to. Is there any way to only have
a report generated for the current data displayed on the
form at that time?
 
Place a command button on your form for printing the current record. Put the
code below in the Click event procedure of the button. It assumes there is a
field named "ID" to uniquely identify the record.

Private Sub cmdPrint_Click()
If Me.Dirty Then
Me.Dirty = False
End Sub
If Me.NewRecord Then
MsgBox "Select a record to print."
Else
DoCmd.OpenReport "MyReport", acViewPreview, , "ID = " & Me.ID
End If
End Sub
 
That's great but is there any way to pick up the ID on the
form automatically so that the user does not have to enter
it?
 
Back
Top