[Last Call] Learn how to a build a cloud-first strategyRegister Now

x
  • Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 366
  • Last Modified:

Access 2010

Hello,

From within my Outlook custom form, I call an Access macro.  The macro runs a query within Access.  The code looks like this:

Myshell.Run chr(34)+"MSACCESS.EXE"+chr(34)+chr(34)+"\\Server1\documents\MyDatabase.mdb"+chr(34)+ " /x mcrOpenDelay"

Open in new window


Is there a way to call an Access macro or query and use a variable.  For instance, I want to run the query, but for a certain job number, so I need to somehow put the job number in the code that calls out the macro or query.

Hope that makes sense,
Joel
0
Genius123
Asked:
Genius123
  • 3
  • 2
1 Solution
 
als315Commented:
You can send parameters to Access and use them in code.
Look help in Access for "command" and you will find examples with code and command lines
0
 
Genius123Author Commented:
I couldn't find anyting in Access that pertained to that.  But found command line examples online, but, nothing that showed me how to pass a parameter through the command line.  Perhaps you can give me an example, or point me in another direction?
0
 
als315Commented:
"c:\Program Files\Microsoft Office\Office14\MSACCESS.EXE"  "\\server\DB\test.accdb" /cmd 1

Open in new window

In code:
Function Start()
Dim C as string
    C = Trim(Command())
If C = "1" Then
            ' some code
ElseIf C = "2" Then
            'some code
else
            'some code
end if
End Function

Open in new window

After /cmd you can send to Access some text string, which should be parsed in VBA code.
Function should be called in your macro

PS. Access has very good help. Create module or open existing. Type "command", select whole word and press F1
0
 
Genius123Author Commented:
Thanks very much, this will work.
0
 
Genius123Author Commented:
Sorry,

I need some extra help on this if you could.

Within Access, I need to paste this into the code so that it reads it upon start up.  But where exactly do I put it within the VB editor?

Function Start()
Dim C as string
    C = Trim(Command())
If C = "1" Then
            ' some code
ElseIf C = "2" Then
            'some code
else
            'some code
end if
End Function
0

Featured Post

Fill in the form and get your FREE NFR key NOW!

Veeam is happy to provide a FREE NFR server license to certified engineers, trainers, and bloggers.  It allows for the non‑production use of Veeam Agent for Microsoft Windows. This license is valid for five workstations and two servers.

  • 3
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now