How about this? Watch for word wrap.
Function OpenCloseAccess()
On Error GoTo ProcError
Dim objAccess As Object
Set objAccess = CreateObject("Access.Application")
objAccess.OpenCurrentDatabase ("Path to your DB") 'Example: ("C:\codescratch\db1.mdb")
' Insert your code here.....
' and close the database when you are finished.
objAccess.CloseCurrentDatabase
ExitProc:
Set objAccess = Nothing
Exit Function
ProcError:
MsgBox "Error " & Err.Number & ": " & Err.Description, , "Error in OpenCloseAccess event
procedure..."
Resume ExitProc
End Function
________________________________________________
What is the vb code to open and close a database. I use
MS access XP. Thanks