Results 1 to 6 of 6

Thread: parameters

  1. #1
    Join Date
    Mar 2003
    Posts
    4

    Unanswered: parameters

    Hi All,

    I have a VB program in a MS Access module. The VBA takes 1 parameter, as in Function Fun(Parm as Long). Questions: How do I call this VBA from a DOS command? And what's the syntax?

    I am a AS/400 programmer and I have to start a job from the 400 which calls a PC program to append records to a MS Access Data base. I have th VBA program working. I know to set up a Macro with a RunCode to call the VBA, but how to pass on the parameter to the Macro?

    Thanks in advance

    Dcheung

  2. #2
    Join Date
    Dec 2002
    Posts
    60

    Re: parameters

    You can start Access with a command line option (/cmd), then use the Command function to retrieve it inside Access (See help under command-line options)

    I don't know if you can use Command function in a Macro, but you could place it in the VBA.

  3. #3
    Join Date
    Mar 2003
    Posts
    4

    Re: parameters

    Thanks for you response. If the VBA doesn't require parameters I can do as below:

    On the C: prompt I put something like C:\"C:\program files\......................\My Documents\Test.mdb" /x mymacro

    where mymacro is a macro which contains RunCode to call the VB.

    But how do I pass a parameter to the macro?

  4. #4
    Join Date
    Oct 2002
    Location
    Leicester - UK
    Posts
    820
    i've never tried it my self but you normaly put a space between the function and the parameter
    Definition of a Beginner, Someone who doesn't know the rules.

    Definition of an Expert, Someone who knows when to ignore the rules.

  5. #5
    Join Date
    Dec 2002
    Posts
    60

    Re: parameters

    Put YourVBACode(Command()) in the 'Function' field of the RunCode line of the Macro, where YourVBACode is the name of the function you are calling in the macro.

    Use following to start access:

    msaccess.exe "databasename" /x "macroname" /cmd "parameter"

    This will pass the parameter to the code. If you want to use the parameter in the macro, try 'Command()' where you want the parameter.

  6. #6
    Join Date
    Mar 2003
    Posts
    4
    Thanks bc301.....works great!!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •