Results 1 to 3 of 3
  1. #1
    3 Star Lounger
    Join Date
    Feb 2004
    Location
    Burgas, Bulgaria
    Posts
    209
    Thanks
    0
    Thanked 0 Times in 0 Posts

    One of the cases (Access 2000)

    In my Select case statement i have 5 cases to open the report.If none of the cases is chosen, i want to open the report only for those customers, for which one of the cases is valid.That is, either trolley is true, or signs is true etc. Can you help me ? My code is the folloiwjg :
    Private Sub Command98_Click()
    Dim strWhere As String

    On Error GoTo Err_Command98_Click

    Select Case Me.Ads
    Case 1
    strWhere = " AND trolley = True"

    Case 2
    strWhere = " AND signs = True"
    Case 3
    strWhere = " AND flags = True"
    Case 4
    strWhere = " AND boilers = True"
    Case 5
    strWhere = " AND Fomex = True"

    End Select

    If Not IsNull(Me.office) Then
    strWhere = strWhere & " AND afid = " & Me.office
    End If

    If Not strWhere = "" Then
    ' Remove first " AND "
    strWhere = Mid(strWhere, 6)
    End If

    DoCmd.OpenReport "rptAds", acViewPreview, , strWhere
    Me.office = Null
    Me.Ads = Null


    Exit Sub

    Err_Command98_Click:
    If Not Err = 2501 Then
    MsgBox Err.description, vbExclamation
    End If

    End Sub

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: One of the cases (Access 2000)

    Insert the following lines immediately above the line End Select:

    Case Else
    strWhere = " AND (trolley=True) + (signs=True) + (flags=True) + (boilers=True) + (fomex=True) = -1"

  3. #3
    3 Star Lounger
    Join Date
    Feb 2004
    Location
    Burgas, Bulgaria
    Posts
    209
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: One of the cases (Access 2000)

    Thank you Hans. That is what i wanted.And naturally it did work this time

Posting Permissions

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