none
Multiple OR in SQL String RRS feed

  • Question

  • I am using a bit a code to Adjust form length and an SQL variable to modify the names that show up in a Combobox. I want to make sure that the names in the Comboboxes above the one that is being worked on, do not show any names. So if Combo1 has 40 names then Combo2 will only have 39 and so on. My problem seems to be when I use multiple "OR" within the WHERE Clause of the SQL String. Can anyone advice?

    Private Sub Worker3_Change()
    Dim Worker4STR As String
    
    'Shows Worker 4
    
    Me.Worker4.RowSource = ""
    Worker4STR = "SELECT T1Workers.NonUserID, T1Workers.[FirstName] & "" "" & [LastName] AS FullName FROM T1Workers WHERE T1Workers.NonUserID <>" & _
                  Me.Worker1.Value & " OR " & Me.Worker2.Value & " Or " & Me.Worker3.Value
    Me.Worker4.RowSource = Worker4STR
    
    Me.Worker4.AllowValueListEdits = False
    Me.Worker4.ColumnCount = 2
    Me.Worker4.ColumnWidths = "0, "
    
    Me.Worker4.Visible = True
    Me.Activity4.Visible = True
    Me.w4a1s.Visible = True
    Me.w4a1d.Visible = True
    Me.w4a1o.Visible = True
    Me.w4a2s.Visible = True
    Me.w4a2o.Visible = True
    Me.w4a2d.Visible = True
    Me.w4a3s.Visible = True
    Me.w4a3o.Visible = True
    Me.w4a3d.Visible = True
    Me.w4a4s.Visible = True
    Me.w4a4o.Visible = True
    Me.w4a4d.Visible = True
    Me.w4a5s.Visible = True
    Me.w4a5o.Visible = True
    Me.w4a5d.Visible = True
    Me.InsideHeight = 1440 * 4.6
    
    End Sub

    I've found in another Forum that I maybe should be using 'IN' or 'NOT IN' instead of 'OR' but I am not sure how to implement... Does anyone have any feedback?

    Wednesday, June 7, 2017 11:13 PM

Answers

All replies