Results 1 to 2 of 2
Thread: yet more sql (2000)
2005-01-12, 16:14 #1
- Join Date
- May 2003
- Manchester, Gtr Manchester, England
- 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
sSELECT = sSELECT & ",Teams.[team manager]" & " ,teams.smt"
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.
2005-01-12, 16:19 #2
- Join Date
- Mar 2002
- Thanked 29 Times in 29 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
If Not IsNull(cmbsmt) Then
sWHERE = sWHERE & " And Teams.SMT = " & cmbsmt