Event?

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Help, please! I have a report which pulls from two different tables through
a query. It pulls the company from the first table and from the second it
pulls investors detail information for that specific company. I would like
to be able to have this report print screen in the actual company and it only
print screen that specific company that I am in instead of the whole report.
Can someone tell me how...I am a beginner as you can tell. I set up a button
in the form for it to print screen the report and it works, it just shows all
the companies instead of just the specific company on the screen. Can anyone
help?
 
Change your button to...


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