Can't launch mde using button on form


M

MrDavePet

Using Win XP Pro, I am trying to launch my O-2003 mde using this code
from a button on a form:

This code works-
Dim stAppName, MyFile As String
MyFile = " C:\_ICDB\ICDBFEr2.mde "
stAppName = "C:\Program Files\Microsoft Office\OFFICE11\MSACCESS.EXE"
& MyFile
Call Shell(stAppName, 1)

The following code does not work. How can I fix it?

Dim stAppName, MyFile As String
MyFile = " C:\Program Files\_ICDB\ICDBFEr2.mde "
stAppName = "C:\Program Files\Microsoft Office\OFFICE11\MSACCESS.EXE"
& MyFile
Call Shell(stAppName, 1)

I get the error "can't find the database c:\Program.mdB" (why MDB)?.
(Yes the file is really at "C:\Program Files\_ICDB\ICDBFEr2.mde"
 
Ad

Advertisements

S

Stefan Hoffmann

hi,

MrDavePet wrpte:
This code works-
Dim stAppName, MyFile As String
In VBA you cannot declare by enum. stAppName is declared as Variant if
you omit the type.
MyFile = " C:\_ICDB\ICDBFEr2.mde "
stAppName = "C:\Program Files\Microsoft Office\OFFICE11\MSACCESS.EXE"
& MyFile
Call Shell(stAppName, 1)
Sure? I don't think so.
I get the error "can't find the database c:\Program.mdB" (why MDB)?.
(Yes the file is really at "C:\Program Files\_ICDB\ICDBFEr2.mde"
The problem is that you need to enclose path/file names in quotes when
they contain spaces:

Dim stAppName As String
Dim MyFile As String

MyFile = """C:\Program Files\_ICDB\ICDBFEr2.mde"""
stAppName = """C:\Program Files\" & _
"Microsoft Office\OFFICE11\MSACCESS.EXE"""

Call Shell(stAppName & MyFile, 1)


mfG
--> stefan <--
 
S

Stefan Hoffmann

hi,
The following code does not work. How can I fix it?
MyFile = " C:\Program Files\_ICDB\ICDBFEr2.mde "
btw, normally users don't have the necessary NTFS permissions to create
the *.ldb file under %PROGRAMFILES%
I get the error "can't find the database c:\Program.mdB" (why MDB)?.
This error is due to the missing quotes as wrote in my other post.




mfG
--> stefan <--
 
Ad

Advertisements

M

MrDavePet

hi,

MrDavePet wrpte:> This code works-

In VBA you cannot declare by enum. stAppName is declared as Variant if
you omit the type.


Sure? I don't think so.


The problem is that you need to enclose path/file names in quotes when
they contain spaces:

   Dim stAppName As String
   Dim MyFile As String

   MyFile = """C:\Program Files\_ICDB\ICDBFEr2.mde"""
   stAppName = """C:\Program Files\" & _
               "Microsoft Office\OFFICE11\MSACCESS.EXE"""

   Call Shell(stAppName & MyFile, 1)

mfG
--> stefan <--

Thanks. That's a lot of """"'s but it works.
 

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