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

    yet more sql (2000)

    Hello, have this code:

    If ckTM And ckSMT Then


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



    If Not IsNull(cmbtm) And Not IsNull(cmbsmt) Then

    sWHERE = sWHERE & " and Teams.[Team Manager]= " & cmbtm & " and Teams.SMT = " & cmbsmt

    End If

    sSELECT = sSELECT & ",Teams.[team manager]" & " ,teams.smt"

    End If


    What it does in short is takes the values of two combo boxes and nulls if those combos are not selected which are built into an sql string. It works fine except when I select one combo value and leave the other null, my where clause falls over, ie, the select statement and from show but with no where?

    Ani ideas please.

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

    Re: yet more sql (2000)

    The line sSELECT = sSELECT does nothing and can be omitted without harm.

    You need to check for each combo box separately:

    If Not IsNull(cmbtm) Then
    sWHERE = sWHERE & " And Teams.[Team Manager]= " & cmbtm
    End If

    If Not IsNull(cmbsmt) Then
    sWHERE = sWHERE & " And Teams.SMT = " & cmbsmt
    End If

Posting Permissions

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