Open another database...

W

Wavequation

I have two front end programs. Can I, via a control button on a form in the
first DB, open a form in the second DB?
 
D

Daniel Pineault

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.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top