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
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