David Peterson
David Peterson

Reputation: 552

Using Shell Open specific ACCESS form

I'm trying to open a specific Access form using Shell in vb6, but after reading lots of documentation, I am unable to find out why Access can not find my database.

dim ss as string
ss = MSAccFolder & "\MSAccess.exe" & " " & app.path & "\database\db.mdb /cmd " & ""formname""
Shell sss, vbNormalFocus

The interesting thing that I shoud tell you is that after a while Access opens and it says that the database with this path does not found

MYAPPPATH/MYFORMNAME.mdb

What's wrong?

Upvotes: 1

Views: 1225

Answers (2)

David Peterson
David Peterson

Reputation: 552

Finally i found the solution.

    Private 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 nShowCmd As Long) As Long

'This will open Access with the specified name

    Dim ss As String
    ss = App.path & "\database\db.mdb"
    ShellExecute Me.hwnd, vbNullString, ss, vbNullString, "C:\", SW_SHOWNORMAL

Upvotes: 0

akton
akton

Reputation: 14386

app.path may contain spaces. Surround app.path & "\database\db.mdb" with quotes. I apologise but I have forgotten the VB syntax to do it.

Upvotes: 3

Related Questions