I have two tables within my database which I need to query within VB. The 1st recordset (RS) will be queried and updated with information from my text import. The 2nd recordset (RSFound) is a lookup query (the SQL statement looks for a variable that was set from the 1st recordset) that will try to match the current record from 1st recordset to the current (only) record from the 2nd recordset. I have one ADO Connection to the database. For some reason the second recordset is not populating. It worked fine in DAO, so I know the SQL statement is correct.
It's at this point where RsFound!Desc gives me the error: "<Method 'Item' of object 'Fields' failed>". There is a field called "Desc" in the "Found" table. The SQL query brings back one record (when run manually). And there have been matches (not that it even got to the point of matching).
The first recordset is kept open because the records aren't added until after this lookup is done.
This code worked fine in DAO, but I wanted to get everything in ADO so that there would be less to package at deployment time.
Any ideas would be appreciated.
Code:
dbpath = App.Path & "\pplog3.mdb"
Dim Conn As ADODB.Connection 'Connection
Dim Rs As ADODB.Recordset 'Recordset
Dim strQuery As String 'Command
Set Conn = New ADODB.Connection
With Conn
.CursorLocation = adUseClient
.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
"Data Source=" & dbpath
.Open
End With
strQuery = "SELECT * from ImportTable"
Set Rs = New ADODB.Recordset
With Rs
Set .ActiveConnection = Conn
.CursorType = adOpenStatic
.CursorLocation = adUseClient
.Source = strQuery
.LockType = adLockOptimistic
.Open
End With
<Code here to import files and parse them into the "tempdesc" and a date variable for matching later>
Dim RsFound As ADODB.Recordset 'Recordset
Dim strQuery2 As String 'Command
strQuery2 = "SELECT Value, Desc, Type, Group FROM Found WHERE Desc = '" & tempdesc & "'"
Set RsFound = New ADODB.Recordset
With RsFound
Set .ActiveConnection = Conn
.CursorLocation = adUseClient
.CursorType = adOpenStatic
.Source = strQuery2
.LockType = adLockReadOnly
.Open
End With
Dim dbdesc As String
dbdesc = RsFound!Desc
It's at this point where RsFound!Desc gives me the error: "<Method 'Item' of object 'Fields' failed>". There is a field called "Desc" in the "Found" table. The SQL query brings back one record (when run manually). And there have been matches (not that it even got to the point of matching).
The first recordset is kept open because the records aren't added until after this lookup is done.
This code worked fine in DAO, but I wanted to get everything in ADO so that there would be less to package at deployment time.
Any ideas would be appreciated.