Question Open MS Access with parameters

xmarabout

New member
Local time
Today, 15:13
Joined
Jan 3, 2018
Messages
4
I need to explain the context of the development:
- User X creates a record (let's call it record "a") in a form or another (let's call it form "b"). At the end of the registration, X click on a button to send an email (through Outlook) to user Y.
- User Y, when receiving the email is supposed to open the DB, the form "b" and the record "a" to modify it.

I would like to reduce the steps for user Y: the idea, in the email is to have a link to open automatically the DB in the form "b" on the record "a"

I tried with a nice command: D:\Documents\Test\bdd.accdb /cmd "b a" and I retrieve the parameters in a startup function launched in the autoexec Macro.

The command works well when it is launched from the Windows command line or as a shortcut but, I am not able to include this line in an email. The problem is the "/" in front of "cmd": Outlook always transforms it in a "" and the the system doesn't recognise the command. I tries to escape this switch with "", with \, etc. unsuccessful !
Please help (PS: it is quite urgent!)
 
make the form the Startup form on your db
or create an Autoexec macro that will
open the form.
 
Sorry, the problem is not the startup function or the autoexec... the problem is upstream: how to create a link with the command line and specially the "/".

Here you have the part of the code where I create (part of) the body of the mail with the "famous" command line to open my DB. The problem is the symbol in red automatically converted into a "" in the email...
Code:
sFile = Application.CurrentProject.Path & "\" & Application.CurrentProject.Name
sFile = sFile & "[B][COLOR=Red]/[/COLOR]cmd 'b a'[/B]"
 
You have to open the actual msaccess.exe executable, and pass the path of the file to be opened, along with any commandline parameters as you've shown.

The issue here is finding the executable path reliably as it's not always in the same place depending on what environment (and installer: msi/ctr) was used.

The path to the executable is stored in the registry. Here's something to get you started:

HKLM\SOFTWARE\Microsoft\Office\14.0\Access\InstallRoot\

(update version numbers, wow64 etc as required, consult the Path value for the actual path: depending on your requirements you may have to incorporate all possible combinations, as is the case for most robust installer scenarios, unfortunately. There's also an API call that can retrieve this for you, but I don't have it offhand).

Once you have the path to the msaccess executable in hand you can then build your command:

(aircode)
Code:
Dim cmd As String
cmd = "C:\program files\Office\msaccess.exe ""c:\path\to\target.accdb"" /cmd ""a b c"""
Shell cmd

hth

edit: here's a link providing two alternative methods to get the full path... I've not tried either (and note that syscmd functions are undocumented: looks easy but take it with a grain of salt) https://stackoverflow.com/questions/10990589/how-do-i-determine-the-ms-access-install-path
 
Last edited:
I've just sent this to myself without any problems, so it is doable with Outlook?

c:\temp\access.accdb /cmd "b a"

both as plain text and as a hyperlink.
Hoever if I click on the hyperlink in the received email it changes /cmd to \cmd and then fails.



I need to explain the context of the development:
- User X creates a record (let's call it record "a") in a form or another (let's call it form "b"). At the end of the registration, X click on a button to send an email (through Outlook) to user Y.
- User Y, when receiving the email is supposed to open the DB, the form "b" and the record "a" to modify it.

I would like to reduce the steps for user Y: the idea, in the email is to have a link to open automatically the DB in the form "b" on the record "a"

I tried with a nice command: D:\Documents\Test\bdd.accdb /cmd "b a" and I retrieve the parameters in a startup function launched in the autoexec Macro.

The command works well when it is launched from the Windows command line or as a shortcut but, I am not able to include this line in an email. The problem is the "/" in front of "cmd": Outlook always transforms it in a "" and the the system doesn't recognise the command. I tries to escape this switch with "", with \, etc. unsuccessful !
Please help (PS: it is quite urgent!)
 
Hoever if I click on the hyperlink in the received email it changes /cmd to \cmd and then fails.

This is exacltly the problem I have

@jleach : In my organisation, I am not allowed to access the registry...

To all: it as to be "agile" the parameters will change from one mail to another.
 

Users who are viewing this thread

Back
Top Bottom