This could have been a test case that was hard-coded into the query to validate the design/results. Other than that, I don't see this doing anything. I believe you can remove it without harm. htwh Steve Medvid
"IT Consultant & Web Master"
"WHERE 1=1" always evaluates to true. Sometimes, when dynamically building a SQL statement with optional WHERE criteria, I will use WHERE 1=1 and then concatenate the other criteria. This may have been done for a similar reason in your example.
If sCrit1 <> "" Then
SQL = SQL & " And " & sCrit1
End If
If sCrit2 <> "" Then
SQL = SQL & " And " & sCrit2
End If
If sCrit3 <> "" Then
SQL = SQL & " And " & sCrit3
End If
This example creates this SQL statement:
Select * From Table Where 1=1 And col2=7 And col5='Denver'
If all three criteria are blank the statement (Select * From Table Where 1=1) will return all records. Terry L. Broadbent
FAQ183-874 contains tips for posting questions in these forums.
NOTE: Reference to the FAQ is not directed at any individual.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.