Code:
putor = 0
strSQL = "SELECT * FROM trafficCountsFiles "
If advanceSearch = "ON" Then
strSQL = strSQL & " where FileName <> 'z' "
If selSiteCode <> "" or selKeyword <> "" Then
strSQL = strSQL & " and ( "
If selSiteCode <> "" Then
strSQL = strSQL & " siteCode LIKE '%" & selSiteCode & "%' "
putor = 1
End If
If selKeyword <> "" and putor = 1 Then
strSQL = strSQL & " OR FileName LIKE '%" & selKeyword & "%' "
End If
If selKeyword <> "" and putor = 0 Then
strSQL = strSQL & " FileName LIKE '%" & selKeyword & "%' "
End If
strSQL = strSQL & " )"
end if
End If
strSQL = strSQL & " ORDER BY siteCode ASC;"
The code above was working perfectly with only 2 fields and one table(Simflex and Andrew helped me with part of the code yesterday).
For the last 2 hours since I joined to another table so I could display more fields, it isn't working anymore.
I have only 6 records on one table and 30 on any table.
Now when I run this code, it says 150 records displayed.
I know there is something seriously wrong the code below.
The below code is one with the join to another table.
Any urgent help would be greatly appreciated.
Code:
putor = 0
strSQL = "SELECT * " & _
"From fctrafic,trafficCountsFiles "
If advanceSearch = "ON" Then
strSQL = strSQL & " where FileName <> 'z' "
If selSiteCode <> "" or selKeyword <> "" Then
strSQL = strSQL & " and ( "
If selSiteCode <> "" Then
strSQL = strSQL & " fctrafic.siteCode = trafficCountsFiles.SiteCode and siteCode LIKE '%" & selSiteCode & "%' "
putor = 1
End If
If selSiteCode <>"" and putor = 1 Then
strSQL = strSQL & "fctrafic.siteCode = trafficCountsFiles.SiteCode "
End If
If selKeyword <> "" and putor = 1 Then
strSQL = strSQL & " OR FileName LIKE '%" & selKeyword & "%' "
End If
If selKeyword <> "" and putor = 0 Then
strSQL = strSQL & " FileName LIKE '%" & selKeyword & "%' "
End If
strSQL = strSQL & " fctrafic.siteCode = trafficCountsFiles.SiteCode "
strSQL = strSQL & ")"
end if
End If
strSQL = strSQL & " ORDER BY siteCode ASC;