Import data from Access Data Base

  • Thread starter Thread starter Kelly
  • Start date Start date
K

Kelly

Hi All, I am using the Office 2000 package.

I have created a template that has numerous Vlookups and
referances to data in a control sheet.

Currently the data that lives in the Control sheet has to
be updated every time a new employee is hired or switches
positions.

This data is already updated via a Access database
employee tbl.

Can anyone help me automate the update of the control
sheet data?

I can't point the main sheet direct to the data base
because...
a) I don't know how and
b) the template is made availible off-line but the Data
base is not


So I think if I can figure out a way to import the data
into my Conrol sheet on demand with the click of a button
I would be a local hero. then I'll share my hero biskit
with you all :0)
 
This example copies data from a table named "Employees" in
the database "database.mdb" on the C: drive to Sheet1
beginning at cell "A1" of your Excel spreadsheet. In the
Visual Basic Editor, under "Tools/References" be sure to
have "Microsoft DAO 3.6 Object Library" selected.

Sub ImportTable()

Dim DB As Database, RS As Recordset
Set DB = OpenDatabase("C:\database.mdb")
Set RS = DB.OpenRecordset("Employees")

Sheets(1).Range("A1").CopyFromRecordset RS

End Sub

Just substitute your database path and table name as
needed.

Hope this helps.
Tokash
 
Back
Top