There are a couple of ways you could approach this. Below is one using
entirely vba
Sub OpenRemoteDbForm(sDbName As String, sDbFormName As String)
On Error GoTo Error_Handler
Dim Aapp As Access.Application
Set Aapp = New Access.Application
Aapp.OpenCurrentDatabase (sDbName) 'Open the requested database
Aapp.Visible = True 'Should the user see the newly
'open database or not
Aapp.DoCmd.OpenForm sDbFormName 'Open the requested form
Error_Handler_Exit:
On Error Resume Next
Exit Sub
Error_Handler:
MsgBox "MS Access has generated the following error" & vbCrLf & vbCrLf &
"Error Number: " & _
Err.Number & vbCrLf & "Error Source: OpenRemoteDbForm" & vbCrLf & "Error
Description: " & _
Err.Description, vbCritical, "An Error has Occured!"
Resume Error_Handler_Exit
End Sub
You'd need to add further error handling to handle exceptions such as the db
is not found, it is already opened exclusively....
--
Hope this helps,
Daniel Pineault
http://www.cardaconsultants.com/
For Access Tips and Examples:
http://www.devhut.net
Please rate this post using the vote buttons if it was helpful.