From: Brad on
We have a VBS Script that initiates a Sub in an Access 2007 DB.

This works nicely.

We now would like to pass a parm from our VBS script to this Sub. It is our
understanding that the "command" field in our VBA code will contain the
passed data.

What we can't figure out is how to code the VBS script to pass the parm to
Access.

An example would be most appreciated.

Thanks,

Brad
From: Tom van Stiphout on
On Tue, 20 Apr 2010 18:59:01 -0700, Brad
<Brad(a)discussions.microsoft.com> wrote:

The way I understand it:
Your vba script invokes the db like this:
<path_to>msaccess.exe <path_to>your.mdb /cmd myCommand
In your startup code in the Access application, you can use the
Command function:
select case Command()
case "this"
'TODO: run this code
case "that"
'TODO: run that code
end select

-Tom.
Microsoft Access MVP


>We have a VBS Script that initiates a Sub in an Access 2007 DB.
>
>This works nicely.
>
>We now would like to pass a parm from our VBS script to this Sub. It is our
>understanding that the "command" field in our VBA code will contain the
>passed data.
>
>What we can't figure out is how to code the VBS script to pass the parm to
>Access.
>
>An example would be most appreciated.
>
>Thanks,
>
>Brad
From: Tony Toews [MVP] on
Tom van Stiphout <tom7744.no.spam(a)cox.net> wrote:

>The way I understand it:
>Your vba script invokes the db like this:
><path_to>msaccess.exe <path_to>your.mdb /cmd myCommand
>In your startup code in the Access application, you can use the
>Command function:

The problem being that the VBS script likely doesn't know the location
of msaccess.exe and/or the location of msaccess.exe might vary from
system to system or from system to Terminal Server.

Tony
--
Tony Toews, Microsoft Access MVP
Tony's Main MS Access pages - http://www.granite.ab.ca/accsmstr.htm
Tony's Microsoft Access Blog - http://msmvps.com/blogs/access/
For a convenient utility to keep your users FEs and other files
updated see http://www.autofeupdater.com/
Granite Fleet Manager http://www.granitefleet.com/
From: Brad on
Tom and Tony,

Sorry, I didn't ask my question very well.

We are getting hung up on the syntax of the VBS Script.

We have the Windows Scheduler fire up a little VBS Script which
in turn fires up a test Access 2007 DB. This works nicely.

We know how to work with the "Command" field once it gets to Acesss.

What we can't figure out is how to code the parameter (that we want to pass
to Access) in the VBS Script that fires up the Access application.

Brad


"Tony Toews [MVP]" wrote:

> Tom van Stiphout <tom7744.no.spam(a)cox.net> wrote:
>
> >The way I understand it:
> >Your vba script invokes the db like this:
> ><path_to>msaccess.exe <path_to>your.mdb /cmd myCommand
> >In your startup code in the Access application, you can use the
> >Command function:
>
> The problem being that the VBS script likely doesn't know the location
> of msaccess.exe and/or the location of msaccess.exe might vary from
> system to system or from system to Terminal Server.
>
> Tony
> --
> Tony Toews, Microsoft Access MVP
> Tony's Main MS Access pages - http://www.granite.ab.ca/accsmstr.htm
> Tony's Microsoft Access Blog - http://msmvps.com/blogs/access/
> For a convenient utility to keep your users FEs and other files
> updated see http://www.autofeupdater.com/
> Granite Fleet Manager http://www.granitefleet.com/
> .
>
From: Hans Up on
Brad wrote:
> We know how to work with the "Command" field once it gets to Acesss.
>
> What we can't figure out is how to code the parameter (that we want to pass
> to Access) in the VBS Script that fires up the Access application.

I experimented with this and I'll show you what I came up with, but not
sure it's what you're after.

My VBS script:

Dim objShell
Dim strExe
Dim strDb
Dim strParam

Set objShell = WScript.CreateObject("WScript.Shell")
strExe = "C:\Program Files\Microsoft Office\OFFICE11\MSACCESS.EXE"
strDb = "C:\Access\wip\version_control\vc.mdb"
strParam = "Hi!"
ObjShell.exec(strExe & " " & strDb & " /cmd " & strParam)
Set ObjShell = Nothing

I have a startup form assigned in my database. So I put this in the
form's open event:

Private Sub Form_Open(Cancel As Integer)
If Len(Command()) > 0 Then
MsgBox "Started with '" & Command() & "'"
End If
End Sub

Tom's Select Case suggestion offers more interesting possibilities.

If this is not helpful, please show us your VBS to help us understand
what you want.