R
richard
Hi
I have a list box in which there are 10 fields shown. I wish for the user to
make selections (multiple if required) and then for them to run a report. I
have the following code (mainly extracted from Martin Greens website) which
is allowing the report to run but my criteria is not being used in the record
selection. There is no other criteria in the reports query so I am looking
for help as to why I am not able to run the report correctly displaying the
users selections
Private Sub cmdRunReport_Click()
Dim db As DAO.Database
Dim varItem As Variant
Dim strCriteria As String
Dim strAssistFMJobs As String
Dim stDocName As String
Dim ctrl As Control
Set ctrl = Me.lstAssistFMJobs
If ctrl.ItemsSelected.Count > 0 Then
For Each varItem In ctrl.ItemsSelected
strAssistFMJobs = strAssistFMJobs & "," &
Me!lstAssistFMJobs.ItemData(varItem) & "'"
Next varItem
strAssistFMJobs = Right(strAssistFMJobs, Len(strAssistFMJobs) - 1)
End If
If Len(strAssistFMJobs) = 0 Then
MsgBox "You did not select anything from the list", vbExclamation,
"Nothing to find!"
Exit Sub
End If
strCriteria = "jobnumber In(" & strAssistFMJobs & ")"
stDocName = "Data Sheet for Clients"
DoCmd.OpenReport stDocName, acViewPreview, strCriteria
End Sub
Thanks
Richard
I have a list box in which there are 10 fields shown. I wish for the user to
make selections (multiple if required) and then for them to run a report. I
have the following code (mainly extracted from Martin Greens website) which
is allowing the report to run but my criteria is not being used in the record
selection. There is no other criteria in the reports query so I am looking
for help as to why I am not able to run the report correctly displaying the
users selections
Private Sub cmdRunReport_Click()
Dim db As DAO.Database
Dim varItem As Variant
Dim strCriteria As String
Dim strAssistFMJobs As String
Dim stDocName As String
Dim ctrl As Control
Set ctrl = Me.lstAssistFMJobs
If ctrl.ItemsSelected.Count > 0 Then
For Each varItem In ctrl.ItemsSelected
strAssistFMJobs = strAssistFMJobs & "," &
Me!lstAssistFMJobs.ItemData(varItem) & "'"
Next varItem
strAssistFMJobs = Right(strAssistFMJobs, Len(strAssistFMJobs) - 1)
End If
If Len(strAssistFMJobs) = 0 Then
MsgBox "You did not select anything from the list", vbExclamation,
"Nothing to find!"
Exit Sub
End If
strCriteria = "jobnumber In(" & strAssistFMJobs & ")"
stDocName = "Data Sheet for Clients"
DoCmd.OpenReport stDocName, acViewPreview, strCriteria
End Sub
Thanks
Richard