Create a list or combo box on a form, and make sure it is bound to the column you will need to generate your report. Usually it is the primary key (column 1) but may also be meaningful data (column 2).
Then place a button on your form to open the report. The wizard may ask for you to make an association from the combo box on the form, but if it doesn't, just add this code:
'=====
Dim stDocName As String
Dim stLink As String
Dim intMyCombo As Integer 'for column 1
'or
Dim stMyCombo As String ' for column 2
intMyCombo = Me.MyComboBox
'or
stMyCombo = Me.MyComboBox
stLink = "[MyFieldValue] = " & intMyCombo ' for integer
'0r
stLink = "[MyFieldValue] = " & "'" & stMyCombo & "'" ' for string
stDocName = "rptMyReportName"
DoCmd.OpenReport, stDocName, acPreview, , stLink
'=====
In this example, MyFieldValue is the column in your report that you want to specify criteria for. This will work if your report is based on a query or table.
You cannot put this in a report, but must put it on a form.
HTH
mmcdonal
|