I got this code and it is very useful for my project.
Sub ToAccess()
Dim axsApp As Object
'Assume Access already open with desired database
Set axsApp = GetObject(, "Access.Application")
Set cdb = axsApp.currentdb
Set rst = cdb.openrecordset("Employees")
Dim iRow As Long 'Excel worksheet row number
'Loop thru first 8 rows on active worksheet and put data from
'first two columns into Access employees table
For iRow = 1 To 8
With rst
.addnew
' read the names from Excel into Access table
!LastName = Cells(iRow, 2)
!FirstName = Cells(iRow, 1)
.Update
End With
Next iRow
End Sub
This code works only if the database is open can this work if the database is closed on the network.
any help will be greately appreciated.
Sub ToAccess()
Dim axsApp As Object
'Assume Access already open with desired database
Set axsApp = GetObject(, "Access.Application")
Set cdb = axsApp.currentdb
Set rst = cdb.openrecordset("Employees")
Dim iRow As Long 'Excel worksheet row number
'Loop thru first 8 rows on active worksheet and put data from
'first two columns into Access employees table
For iRow = 1 To 8
With rst
.addnew
' read the names from Excel into Access table
!LastName = Cells(iRow, 2)
!FirstName = Cells(iRow, 1)
.Update
End With
Next iRow
End Sub
This code works only if the database is open can this work if the database is closed on the network.
any help will be greately appreciated.