Open Database from Form

Kinger43

racecar driver
Local time
Today, 07:24
Joined
Aug 17, 2007
Messages
226
Is it possible to open a database from a form in a different database? Not necessary to do so; it would just be handy to do from the form I already have up and looking at rather than having to go open another instance of access and go to that database.
 
You could use Shell or FollowHyperlink. More info on both in VBA Help.
 
Code:
Public Function OpenDatabase()
On Error GoTo Err_OpenDatabase
    
    Dim database
    Dim turtlemeter As String
    turtlemeter = "s:/AccessDB/Turtle_Meter"
    database = Shell(turtlemeter, vbNormalFocus)

Exit_OpenDatabase:
    Exit Function
    
Err_OpenDatabase:
    MsgBox Err.Description
    Resume Exit_OpenDatabase
    
End Function

I call this function from a form with a button click. It gives me a File not found message. I know the file is there, can anyone tell me what may be wrong?
 
Have you tried

turtlemeter = "s:/AccessDB/Turtle_Meter.mdb"

Make sure you have the full name of your db file.
 
Says "Invalid procedure call or argument"
 
You going to have to tell shell to use Ms Access to open your file so try

turtlemeter = " C:\ path to Acces\msaccess.exe s:/AccessDB/Turtle_Meter"

Remember that your DB is not a executable file - it is a datafile for msaccess to use.
 
That didn't work either. I tried just opening access without the database and it wouldn't do that either. It just said file not found. I'm new with VB so I really don't know what all capabilities I have with it. I figured this would be a good learning experience but it has become more of a challenge than I expected.
 
That didn't work either. I tried just opening access without the database and it wouldn't do that either. It just said file not found. I'm new with VB so I really don't know what all capabilities I have with it. I figured this would be a good learning experience but it has become more of a challenge than I expected.
Try looking at Followhyperlink. That might be a better solution for you. There is info in VBA help.
 
Here's a working example:

Code:
  Dim intTest          As Integer

  intTest = Shell("C:\Program Files\Microsoft Office\Office\winword.exe C:\AccessAp\test.doc", vbNormalFocus)
 

Users who are viewing this thread

Back
Top Bottom