Results 1 to 3 of 3
  1. #1
    Silver Lounger
    Join Date
    Jun 2001
    Location
    Niagara Falls, New York, USA
    Posts
    1,878
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Need Proper Macro Syntax? (a2k (9.0.6926) SP-3 Jet 4.0 SP-7)

    When I open a database I want to set a global variable within a Autoexec macro.

    I am opening a database with the following command:

    "C:Program FilesMicrosoft Office2kOfficeMSACCESS.EXE" "F:AppsAccess2kBtfProbLog.mdb" /cmd "SBF"

    In a Autoexec macro I want to run the following code:

    gloSetValue "ProfileCode", Left(Command(), 3)

    Looking for proper macro syntax for the above command?

    This is my gloSetValue code:

    mod_Global_Collection_Variables

    Public Sub gloSetValue(ByVal vstrParamName As String, ByVal vvarValue As Variant)
    On Error Resume Next
    gloMyVariables.Remove vstrParamName
    gloMyVariables.Add vvarValue, vstrParamName
    End Sub

    Thanks, John

  2. #2
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts

    Re: Need Proper Macro Syntax? (a2k (9.0.6926) SP-3 Jet 4.0 SP-7)

    You can only execute functions in a macro, not procedures (subs). The easiest way to do what you want is to create a function

    Public Function StartFunc()
    gloSetValue "ProfileCode", Left(Command(), 3)
    End Function

    and put a RunCode action in your AutoExec macro, with StartFunc() as Function Name argument.

  3. #3
    Silver Lounger
    Join Date
    Jun 2001
    Location
    Niagara Falls, New York, USA
    Posts
    1,878
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Need Proper Macro Syntax? (a2k (9.0.6926) SP-3 Jet 4.0 SP-7)

    Thanks for my first pleasant experience with a macro

Posting Permissions

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