Shell command syntax problem

Keith Nichols

Registered User.
Local time
Today, 13:36
Joined
Jan 27, 2006
Messages
431
Hi Guys,

I have a shell command that I use to open an update.mdb for replacing the FE with the current version.

I managed to get the update.mdb running from a macro but with the shell command, all I seem to be able to do is to run Access, not the target database. I'm sure this is something to do with the quotation marks but I can't figure it.:confused:

Code:
Private Sub cmd_Update_A2003_Click()
On Error GoTo Err_Handler

' call the Utility database and close the Project Tracking database

Dim Updatemdb As String
Updatemdb = Shell("C:\Program Files\Microsoft Office\Office11\msaccess.exe C:\EDT DB\FE_Update.mdb", 1)     ' Run Access

DoCmd.Quit

Exit_Here:
    Exit Sub

Err_Handler:
    MsgBox "Error detected"
    Resume Exit_Here
End Sub

As always, any guidance gratefully received.

Regards,

Keith.
 
Let try to use this code friend :D

Dim rc
rc = Shell("explorer.exe" & filepath)
It's working !Goodluck!
 
Searching the forum is a great way to discover and learn the answers to your Access programming questions.

I prefer to use the ShellExecute method to open a file. It does not have the problems and limitations that the Shell() function does.

I have a working example in my Browse [Find a directory or file] sample.
 
ghudson said:
Searching the forum is a great way to discover and learn the answers to your Access programming questions.

I prefer to use the ShellExecute method to open a file. It does not have the problems and limitations that the Shell() function does.

I have a working example in my Browse [Find a directory or file] sample.

Hi ghudson,

I did use the search, which is where I initially learnt about the shell method although it didn't come up with the ShellExecute method.

I looked at your sample database on the other thread, many thanks for that, but it was way too advanced for me to follow what was going on. :confused:

Also, learning Access Programming on the hoof, so to speak, means that I often haven't the understanding to benefit from the help files. I have a few good text books, but haven't ventured into the VBA sections yet due to time considerations. Having said that, I think I would have recovered the time by now in avoided frustrations and endless quests to solve seemingly "easy" problems if only I had.

Importantly, whoever inherits the database I'm developing from me will probably be an Access newbie as well, and so I can't put in anything that I cannot clearly explain otherwise it will be all but unmaintainable.

Anyway, I worked around my problem by using macros which work fine. I think it probably would be better to 'crack' the shell method, but the KISS principle is overriding here.

Once again, thanks for the reply anyway.

Regards,
 
clerics said:
Let try to use this code friend :D

Dim rc
rc = Shell("explorer.exe" & filepath)
It's working !Goodluck!

Hi Clerics,

I tried this everywhich way but loose. I couldn't get it to open a specific Access mdb.

What I really want, is to open a database with command line switches to specify a particular workgroup information file and user. My intention is that the code would identify the version of access and the wif and then be able to use the relevant code to open the target db. Some users are on A2k and others on A2003 so Icanot use the same command for each.

As it is, I am using 2 update.mdb's called by separate macros. When the front end update is complete, the mdb shows a message telling the user they can restart the database. If I could crack the shell method, I could automate this process fully and make it invisible to the end user.

Just a thought, but do you have a sample database with this method in it? Maybe with a working example I could identiy where I am going wrong.

Anyway, thanks for the response.

Kind regards,
 
Macros do not allow you to trap for expected and/or unexpected runtime errors.
 
Searching the forum is a great way to discover and learn the answers to your Access programming questions.

The acSysCmdAccessDir command will tell you where the MSACCESS.EXE file is located on the users computer.
Code:
(SysCmd(acSysCmdAccessDir))
Use message boxes to display your string(s) so that you can see what you are calling to the Shell() while you are trying to figure this stuff out.
Code:
MsgBox "acSysCmdAccessDir = " & (SysCmd(acSysCmdAccessDir))
 
Shel("explorer.exe" & filepath) --> i mean the full path to "explorer.exe"
this Command 's just like you double click on that Access file .So it means this access file will be opened by your current version Access ! I use this manytime cuz it s very simple ! But if it doesnt like which you want to do :D ---> ghudson is very nice with this one ! Good luck friend !
 

Users who are viewing this thread

Back
Top Bottom