Dim dlg As Office.FileDialog, path as String
Set dlg = Application.FileDialog(msoFileDialogFilePicker)
dlg.Filters.Clear
dlg.Filters.Add "Access Files", "*.accbd"
dlg.FilterIndex = 0
dlg.Show
If dlg.SelectedItems.Count > 0 Then
Dim cn As ADODB.Connection, rs As ADODB.Recordset, i As Long, lastrow As Long
' connect to the Access database
Set cn = New ADODB.Connection
'define and open a recordset from the specified database path and database table name. Change it to suit your need.
cn.Open "Provider=Microsoft.ACE.OLEDB.12.0;" & " Data Source=" & dlg.selecteditems(1)
Set rs = New ADODB.Recordset
rs.Open "ORMC_DISCHARGE", cn, adOpenKeyset, adLockOptimistic, adCmdTable
lastrow = ActiveSheet.UsedRange.Rows.Count
End If
Bookmarks