Opening another database

D

Duane

I am wondering if it is possible to open an different database from a
Command Button? I have tried using the Shell Fucntion. I can open the
MSAccess.exe file without any problems, but not an .mdb file

Dim RetVal
RetVal = Shell("C:\Temp\OTEqualization.mdb", 3) ' Open OTEqual.

Error: Invalid Procedure Call or Argument

Do I need to go about this a totally different way?

Thank you.
 
F

fredg

I am wondering if it is possible to open an different database from a
Command Button? I have tried using the Shell Fucntion. I can open the
MSAccess.exe file without any problems, but not an .mdb file

Dim RetVal
RetVal = Shell("C:\Temp\OTEqualization.mdb", 3) ' Open OTEqual.

Error: Invalid Procedure Call or Argument

Do I need to go about this a totally different way?

Thank you.

Application.FollowHyperlink "C:\Temp\OTEqualization.mdb"
 
D

Duane

Thank you very much. I will give that a try.


KenSheridan via AccessMonster.com said:
This has always worked for me:

1. Add the following module to the database:

''''module starts''''
Option Compare Database
Option Explicit

Declare Function ShellExecute& Lib "shell32.dll" Alias "ShellExecuteA"
(ByVal
_
hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal _
lpParameters As String, ByVal lpDirectory As String, ByVal nshowcm As
Long)

Sub ShellToFile(strPath As String, ByVal lngHwnd As Long)

Dim lngRetVal As Long

lngRetVal = ShellExecute(lngHwnd, "open", strPath, _
vbNullString, CurDir, 1)

If lngRetVal < 32 Then
MsgBox "Unable to open file " & strPath, vbInformation, "Warning"
End If

End Sub
''''module ends

2. Then call the ShellToFile function in the button's Click event
procedure:

ShellToFile "C:\Temp\OTEqualization.mdb", Me.Hwnd

Ken Sheridan
Stafford, England
 
D

Duane

Worked great Ken. Thanks again.

KenSheridan via AccessMonster.com said:
This has always worked for me:

1. Add the following module to the database:

''''module starts''''
Option Compare Database
Option Explicit

Declare Function ShellExecute& Lib "shell32.dll" Alias "ShellExecuteA"
(ByVal
_
hwnd As Long, ByVal lpOperation As String, ByVal lpFile As String, ByVal _
lpParameters As String, ByVal lpDirectory As String, ByVal nshowcm As
Long)

Sub ShellToFile(strPath As String, ByVal lngHwnd As Long)

Dim lngRetVal As Long

lngRetVal = ShellExecute(lngHwnd, "open", strPath, _
vbNullString, CurDir, 1)

If lngRetVal < 32 Then
MsgBox "Unable to open file " & strPath, vbInformation, "Warning"
End If

End Sub
''''module ends

2. Then call the ShellToFile function in the button's Click event
procedure:

ShellToFile "C:\Temp\OTEqualization.mdb", Me.Hwnd

Ken Sheridan
Stafford, England
 
D

Duane

Yours worked good too Fred. In fact, yours opened the database even faster.
The down side to using the Application.FollowHyperlink is that when I closed
the database it asked me for a password. There isn't a password set for the
database. I can cancel the prompt and the database closed okay. What could
have been worse is that it now it asks for a password to open the database
back up. Not good. Glad I used a copy and not the real thing.
 

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