How to select records from a combo or list box to print a report?

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

Guest

Would like to print a report in Access 2003 showing only the record selected
from a combo/list box. How can it be done?

Thanks!

Jose.
 
there are three ways you can use
1. on the print button enter the code, assigning a where condition
' if value number
docmd.OpenReport "ReportName",,,"MyFieldInTable= " & me.combovalue
' if value text
docmd.OpenReport "ReportName",,,"MyFieldInTable= '" & me.combovalue & "'"

2. On the open event of the report you can assign the recordsource for the
report with the filter entered in the form
' For String
me.recordsource = "Select * From MyTable Where MyField = '" &
forms![FormName]![FieldName] & "'"

' For number
me.recordsource = "Select * From MyTable Where MyField = " &
forms![FormName]![FieldName]

3. Put the name of the combo from the form as the filter in recordsource of
the report

Select * From MyTable Where MyField = forms![formName]![FieldName]
 
Back
Top