monroeski
07-31-2005, 11:42 AM
I am trying to dynamically create a report in Access 97. For some reason, every time I hit the button to preview the report, it brings me up a message box for each of the items that are selected in List8 and asks for input (for example, if I select "window" and "carpet," a box will pop up that says "carpet" with a text box below it. If I do not type "carpet" into the box, it won't show up on the report. Hit OK, then a box with "window" shows up, then hit OK and the report preview finally shows up).
Here's my code -
Dim frm As Form, ctl As Control
Dim varItem As Variant
Dim strSQL As String
If List8.ItemsSelected.Count = 0 Then
MsgBox ("Please select one or more problem types")
Else
strSQL = "probtype="
For Each varItem In List8.ItemsSelected
strSQL = strSQL & List8.ItemData(varItem) & " OR probtype="
Next varItem
strSQL = Left$(strSQL, Len(strSQL) - 13)
DoCmd.OpenReport "Dynamic", acViewPreview, , strSQL
End If
End Sub
Here's my code -
Dim frm As Form, ctl As Control
Dim varItem As Variant
Dim strSQL As String
If List8.ItemsSelected.Count = 0 Then
MsgBox ("Please select one or more problem types")
Else
strSQL = "probtype="
For Each varItem In List8.ItemsSelected
strSQL = strSQL & List8.ItemData(varItem) & " OR probtype="
Next varItem
strSQL = Left$(strSQL, Len(strSQL) - 13)
DoCmd.OpenReport "Dynamic", acViewPreview, , strSQL
End If
End Sub