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 SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Add record from excel into access 1

Status
Not open for further replies.

JohnAcc

Technical User
Aug 13, 2003
143
0
0
GB
Hi there,

I am trying to add data from Excel into access using the following code but it doesn't work. I do not get any error message:

Private Sub CbAdd_Click()

Dim Db As Database
Dim Rs As Recordset

Set Db = OpenDatabase("T:\Accounts\John Cox\db1.mdb")

' open the database
Set Rs = Db.OpenRecordset("Client", dbOpenTable)

' Add a new record into the database

With Rs
.AddNew ' create a new record
' add values to each field in the record
.Fields("Name") = Workbooks("Book2").Sheets("Sheet1").Range("E2").Value
.Fields("Age") = Workbooks("Book2").Sheets("Sheet1").Range("F2").Value
End With

End Sub

Any help is much appreciated.

Rgds, John




 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top