Question : sql string in VB

I have a form where user enters begin and end date along with a few other selections. The date selections are not working correctly. This is used for many report selections. It would be nice to get it working correctly. The code is as follows.
If Me!cboStatus = "Open During Date Range" Then
        strWhere1 = " AND tblClient.ClientOpened <= #" & Me!txtEndDate & "# AND (tblClient.ClientClosed >= #" & Me!txtStartDate & "# OR tblClient.ClientClosed Is Null)"
        i = 1
    ElseIf Me!cboStatus = "Opened Between Date Range" Then
        strWhere1 = " AND tblClient.ClientOpened >= #" & Me!txtStartDate & "# AND tblClient.ClientOpened <= #" & Me!txtEndDate & "#"
        i = 1
    Else
        strWhere1 = " AND tblClient.ClientClosed >= #" & Me!txtStartDate & "# AND tblClient.ClientClosed <= #" & Me!txtEndDate & "#"
        i = 1
    End If
Now if I do between this runs ok but will leave out some clients that should be included. It need to be an AND statement because I am already using Where for something else. Can anyone help with this?
Thanks in advance.

Answer : sql string in VB

Debug your code so that you can see the final statement after the SQL string has been built. i.e. set a watch on the variable that holds your completed SQL string, or better:
debug.print yourSQLStringVariable

If the problem isn't obvious from inspecting that, please post the result of that debug line. You could also try using the text that is printed to debug (immediate window) in the SQL view of the query builder, then try to run the query.

I can't help you without seeing the complete SQL statement.

Simon
Random Solutions  
 
programming4us programming4us