I'm using Office 2003 on Xp sp2.
Please notice that this VBA code works and produces
a record set which contains the desired data if the WHERE
clause is omitted. When, however, the code is run as presented
below, the recordset remains empty. There definitely is the
correct data eg. "Cat" in the Table1.Table1_N ame field of
the testData.mdb database. Am I doing something wrong with
the delimiters around 'C*' in the SQL?
Any help is appreciated.
Gregg
Please notice that this VBA code works and produces
a record set which contains the desired data if the WHERE
clause is omitted. When, however, the code is run as presented
below, the recordset remains empty. There definitely is the
correct data eg. "Cat" in the Table1.Table1_N ame field of
the testData.mdb database. Am I doing something wrong with
the delimiters around 'C*' in the SQL?
Code:
Private Sub Command5_Click() Dim rs0 As New ADODB.Recordset Dim AccessConnect As String ' the connection string AccessConnect = _ "Driver={Microsoft Access Driver (*.mdb)};" & _ "Dbq=testData.mdb;" & _ "DefaultDir=C:\test;" & _ "Uid=Admin;Pwd=;" ' the query string QueryString = "SELECT Table1.Table1_Name FROM Table1 " & _ "WHERE Table1.Table1_Name LIKE 'C*';" Debug.Print QueryString rs0.Open QueryString, AccessConnect, adOpenStatic rs0.MoveFirst '<- error is generated if recordset is empty rs0.Close End Sub
Gregg
Comment