Hi guys,
I have a form on a database - This form has a button which, when clicked, opens another database for the user. I want the button to set focus to the database if it's already open - Here is the code I have so far:
Private Sub Command1_Click()
Dim appAccess As Access.Application
Dim strDB As String
Dim strUName As String
Const strConPathToSamples = "C:\Documents and Settings\"
strUName = Environ("Username")
Const strFolderC = "\My Documents\Trusted\"
strDB = strConPathToSamples & strUName & strFolderC & "locations.accdb"
Set appAccess = CreateObject("Access.Application")
appAccess.OpenCurrentDatabase strDB, False
Set appAccess = Nothing
End Sub
this code keeps opening the database everytime I click the button. how can I prevent this?
thanks for all the help!
I have a form on a database - This form has a button which, when clicked, opens another database for the user. I want the button to set focus to the database if it's already open - Here is the code I have so far:
Private Sub Command1_Click()
Dim appAccess As Access.Application
Dim strDB As String
Dim strUName As String
Const strConPathToSamples = "C:\Documents and Settings\"
strUName = Environ("Username")
Const strFolderC = "\My Documents\Trusted\"
strDB = strConPathToSamples & strUName & strFolderC & "locations.accdb"
Set appAccess = CreateObject("Access.Application")
appAccess.OpenCurrentDatabase strDB, False
Set appAccess = Nothing
End Sub
this code keeps opening the database everytime I click the button. how can I prevent this?
thanks for all the help!