VERY small VB/MS Access problem

Sharky Forums


Results 1 to 1 of 1

Thread: VERY small VB/MS Access problem

Threaded View

  1. #1
    Has got that jut monroeski's Avatar
    Join Date
    Nov 2002
    Posts
    8,055

    VERY small VB/MS Access problem

    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
    Last edited by monroeski; 07-31-2005 at 11:44 AM.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •