Creating a Database Form From an Excel Worksheet in worksheet activate event
Private Sub Worksheet_Activate()
Dim dbNorthwind As DAO.Database
Dim rsCategories As DAO.Recordset
Dim dbpath As String
dbpath = CurrentPath & "\mydb.mdb"
Set dbNorthwind = OpenDatabase(dbpath)
Set rsCategories = dbNorthwind.OpenRecordset( _
"Categories", dbOpenTable)
With rsCategories
If Not .BOF Then .MoveFirst
Cells(3, 3).Value = .Fields(1).Value 'Name
Cells(5, 3).Value = .Fields(2).Value 'Description
End With
End Sub
Related examples in the same category