SQL and Access query BETWEEN Help

Hey guys

I have a SQL query that fills a record set and then displays the result in a text box but the query is not working the syntax I think is right but the record set does not get filled.

Here is the code

Dim sqlstring As String
Dim myRS As New ADODB.Recordset

Set myConnection = New ADODB.Connection
myConnection.Open "PROVIDER=Microsoft.jet.OLEDB.4.0;data source=" & App.Path & "DatabaseDatabase.mdb" & ";"

myRS.CursorLocation = adUseClient
sqlstring = "SELECT CLIENT.CSURNAME,CLIENT.CFIRST,CLIENT.STREET,CLIENT.STREET2 FROM CLIENT, TREAT WHERE TREAT.DATE BETWEEN " & CDate(CustomStartDate) & " AND " & CDate(CustomEndDate) & ""
Set myRS = myConnection.Execute(sqlstring)


Do Until myRS.EOF
If IsNull(myRS!Street2) = True Then
txtResults.SelText = myRS!CFIRST + " " + myRS!CSURNAME + " " + myRS!Street + vbCrLf
Else
txtResults.SelText = myRS!CFIRST + " " + myRS!CSURNAME + " " + myRS!Street + " " + myRS!Street2 + vbCrLf
End If
myRS.MoveNext
Loop

myRS.Close

Please can you guys help

Thanks

Skyaxe
Sign In or Register to comment.

Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories