Results 1 to 3 of 3
  1. #1
    4 Star Lounger
    Join Date
    May 2003
    Location
    Manchester, Gtr Manchester, England
    Posts
    552
    Thanks
    0
    Thanked 0 Times in 0 Posts

    more sql syntax (2000)

    Hi, this code takes the value from a combo and builds a string to run a query. How can i code it so that if no value is selected from the combo then all entries are displayed.

    If ckSMT then

    sSELECT = sSELECT
    sFROM = sFROM & " INNER JOIN (Individuals INNER JOIN Teams ON Individuals.Team = Teams.[Team ID]) ON tblmain.Customer = Individuals.[Individual ID]"


    sWHERE = " And [Teams].[smt]= " & cmbsmt

    End If

    So in pseudo, if my user clicks cktsmt but doesn't select from cmbsmt then the query shows all smts?

    Thanks Darren.

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

    Re: more sql syntax (2000)

    Change

    sWHERE = " And [Teams].[smt]= " & cmbsmt

    to

    If Not IsNull(cmbsmt) Then
    sWHERE = " And [Teams].[smt]= " & cmbsmt
    End If

    If nothing is selected from the combo box, sWHERE is not populated (i.e. remains empty).

  3. #3
    4 Star Lounger
    Join Date
    May 2003
    Location
    Manchester, Gtr Manchester, England
    Posts
    552
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: more sql syntax (2000)

    Lovely

    Thanks.

Posting Permissions

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