Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.
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!!!
0 · ·