D
Deleted member 73419
Guest
What is it with access queries? I have the following code which does not seem to return any records.
As part of the code below, I am executing this query
which doesn't seem to return any records. However if I copy and paste this into the MS Access query editor it find a number of records.
How can Access query editor manage to find records and ADODB can't :banghead:
What is going on?
The full code is
As part of the code below, I am executing this query
Code:
SELECT CODE,[SEQUENCE],[BLOCK],[ATTRIBUTES] FROM [analog] WHERE ([ATTRIBUTES] like '*TAG=*');
How can Access query editor manage to find records and ADODB can't :banghead:
What is going on?
The full code is
Code:
Public Sub OpenSchemaX()
Dim Conn As ADODB.Connection
Dim rsSchema As ADODB.Recordset
Dim rsData As ADODB.Recordset
Dim cm As ADODB.Command
Dim strConn As String
Dim count As Integer
Dim strWhereClause As String
Set Conn = New ADODB.Connection
Set Conn = CurrentProject.Connection
Set rsSchema = Conn.OpenSchema(adSchemaTables)
Set rsData = New ADODB.Recordset
rsData.CursorLocation = adUseClient
rsData.CursorType = adOpenStatic
count = 0
Do Until rsSchema.EOF
If (Right(rsSchema.Fields("TABLE_NAME"), 4) = "Data") Then
count = count + 1
Debug.Print "Table " & count & " name: " & rsSchema.Fields("TABLE_NAME") & vbCr & "Table type: " & rsSchema.Fields("TABLE_TYPE") & vbCr
Dim t As String
t = "SELECT CODE,[SEQUENCE],[BLOCK],[ATTRIBUTES] FROM [analog] WHERE ([ATTRIBUTES] like '*TAG=*');"
Set rsData = Conn.Execute(t)
rsData.MoveLast
If (Not rsData.RecordCount = -1) Then
rsData.MoveFirst
Do Until (rsData.EOF)
Debug.Print Space(4) & rsData.Fields("Code").Value & vbCr & _
Space(4) & rsData.Fields("Sequence").Value & vbCr & _
Space(4) & rsData.Fields("Code").Value & vbCr & _
Space(4) & rsData.Fields("Attributes").Value & vbCr
rsData.MoveNext
Loop
End If
rsData.Close
Set cm = Nothing
End If
rsSchema.MoveNext
Loop
rsSchema.Close
Conn.Close
Set rsSchema = Nothing
Set Conn = Nothing
End Sub