Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Pulling data from Access into another MS App (via DAO)

VBA How To

Pulling data from Access into another MS App (via DAO)

by  RSi2  Posted    (Edited  )
Tested in Excel. Good Luck [pc3]

Private Sub CommandButton1_Click()

'In Tools / References include "Microsoft DAO 3.51"
Dim oWorkspace As DAO.Workspace
Dim oDatabase As DAO.Database
Dim oRecordset As DAO.Recordset
Set oWorkspace = DAO.CreateWorkspace("", "admin", "", dbUseJet)
Set oDatabase = oWorkspace.OpenDatabase("d:\test\vb\bd1.mdb")
Set oRecordset = oDatabase.OpenRecordset("Table1")

oRecordset.MoveFirst
While Not oRecordset.EOF
'your code here
MsgBox (oRecordset.Fields("test").Value)
'ok, go next
oRecordset.MoveNext
Wend

oRecordset.Close
oDatabase.Close
oWorkspace.Close

End Sub
Register to rate this FAQ  : BAD 1 2 3 4 5 6 7 8 9 10 GOOD
Please Note: 1 is Bad, 10 is Good :-)

Part and Inventory Search

Back
Top