G
Guest
I'm having trouble getting a recordset object from an external Access DB
using a form.
The tb object works giving me recordcounts and whatnot from the table in the
external database
But the recordset won't work. I want to pull values in fields: Rval =
rs.Fields(i).Value
Am I missing something?
Dim Qry1 As String, TabStr1 As String
Dim FileToOpen As String
Dim DB As Database
Dim tb As TableDef
Dim rs As Recordset
FileToOpen = Me.DBox.Value 'External DB Filename
TabStr1 = "[" & Me.TableBox.Value & "]" 'Table name
Qry1 = "SELECT * FROM " & TabStr1
Set DB = DBEngine.Workspaces(0).OpenDatabase(FileToOpen)
Set rs = DB.OpenRecordset(Qry1, dbOpenSnapshot)
Set tb = DB.TableDefs(Me.TableBox.Value)
MsgBox "Importing " & tb.RecordCount & " records from " & _
tb.Fields.Count & " fields with the statement" & vbCr & Qry1
Dim Rval
dim i as integer
for i = 0 to 10
Rval = rs.Fields(i).Value
msgbox Rval
next i
using a form.
The tb object works giving me recordcounts and whatnot from the table in the
external database
But the recordset won't work. I want to pull values in fields: Rval =
rs.Fields(i).Value
Am I missing something?
Dim Qry1 As String, TabStr1 As String
Dim FileToOpen As String
Dim DB As Database
Dim tb As TableDef
Dim rs As Recordset
FileToOpen = Me.DBox.Value 'External DB Filename
TabStr1 = "[" & Me.TableBox.Value & "]" 'Table name
Qry1 = "SELECT * FROM " & TabStr1
Set DB = DBEngine.Workspaces(0).OpenDatabase(FileToOpen)
Set rs = DB.OpenRecordset(Qry1, dbOpenSnapshot)
Set tb = DB.TableDefs(Me.TableBox.Value)
MsgBox "Importing " & tb.RecordCount & " records from " & _
tb.Fields.Count & " fields with the statement" & vbCr & Qry1
Dim Rval
dim i as integer
for i = 0 to 10
Rval = rs.Fields(i).Value
msgbox Rval
next i