query question

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • crazytegger
    New Member
    • May 2006
    • 22

    query question

    Here is my query, im trying to filter items using a string but also including null values. I also give the option of searching current, discontinued, or all items. the problem is when there is a null value, the query displays that item regardless of the itemstatus im searching for. I hope this isnt too confusing. can somone help please???

    If Me.ItemStatus = "1" Then
    strcrit1 = "(((items.itemd iscontinued)=(F alse)))"
    ElseIf Me.ItemStatus = "2" Then
    strcrit1 = "(((items.itemd iscontinued)=(T rue)))"
    ElseIf Me.ItemStatus = "3" Then
    strcrit1 = "(not(isnull(it ems.itemid)))"
    End If

    strSQL = "SELECT [itemid], [itemname], [itemdescription], [itemsupplierid], suppliers.[suppliername], [itemmanufacture r], [itemproductnumb er], [itemdiscontinue d] " & _
    "FROM items " & _
    "INNER JOIN suppliers ON suppliers.[supplierid] = items.[itemsupplierid] " & _
    "WHERE " & strcrit1 & " " & _
    "AND " & Forms.frmItems. cmbSearchField & " Like '" & Me.txtSearchCri teria & "*' " & _
    "OR " & Forms.frmItems. cmbSearchField & " IS NULL " & _
    "ORDER BY " & Forms.frmItems. cmbSearchField & ";"
Working...