Hey Guys I need help with SQL and VB 6.
What I am trying to do is make a query that tells me how has not visited a shop with a time period. I am using 2 tables in my query. Here is the code I have so far
Dim sqlstring As String
Dim myRS As New ADODB.Recordset
Dim LastMonth As Date
LastMonth = Date - 31
Set myConnection = New ADODB.Connection
myConnection.Open "PROVIDER=Microsoft.jet.OLEDB.4.0;data source=" & App.Path & "DatabaseDatabase.mdb" & ";"
sqlstring = "SELECT C1.CSURNAME, C1.CFIRST FROM CLIENT C1 WHERE NOT EXISTS (SELECT *FROM CLIENT C2, TREAT T WHERE C2.CCODE = C1.CCODE AND T.CCODE = C2.CCODE ANDT.DATE > " & LastMonth & ")"
myRS.CursorLocation = adUseClient
Set myRS = myConnection.Execute(sqlstring)
Do Until myRS.EOF
If IsNull(myRS!STREET2) = True Then
txtResults.SelText = myRS!CFIRST + " " + myRS!CSURNAME + " " + myRS!Street + vbCrLf
txtResults.SelText = myRS!CFIRST + " " + myRS!CSURNAME + " " + myRS!Street + " " + myRS!STREET2 + vbCrLf
But there is an Syntax error in the query somewhere and I cant see it. I cant find any websites to help me!
So you guys are my last hope!!!