RunCode macro

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Jeff_F

    #1

    RunCode macro

    Trying to use the run code macro, but there seems to be problems with
    connecting and running the function, in a module, I have selected. It
    seems there are problems in the arguments, which I am entering in the
    "action window". I am entering:

    ChangeProperty_ DB_Window(strPr opName As String, varPropType As Variant,
    varPropValue As Variant) As Integer

    and I am getting an info box saying:

    ...."can't find the name 'strPropName'yo u entered in the expression"

    tried a few different combinations of the arguments - no luck.

    While I'm at it, anyone know how I would call a sub procedure from a
    function - which I will also need to use this RunCode macro(seperate
    issue from above).


    J

  • lauren quantrell

    #2
    Re: RunCode macro

    A couple of things...
    Did you create the property before trying to change it?

    Code: (assuming it is an Access Project:

    Function AddProp(propNam e As String, propValue)
    On Error GoTo myErr
    ' Add a custom property to the properties collection

    With CurrentProject. Properties
    .Add propName, propValue
    End With

    myExit:
    Exit Function
    myErr:
    MsgBox Err.Number & " - " & Err.Description
    Resume myExit
    End Function

    On the "sub procedure" is this a sub that's in a form module?
    There's ways to call this, but better to put it in a module and call
    it:

    Call mySubName

    Public Sub mySubName
    Beep
    End Sub

    Comment

    • lauren quantrell

      #3
      Re: RunCode macro

      Jeff,
      This will probably be more helpful than my previous post since it is
      for an Access MDB rather than an Access ADP. I am huessing you have an
      Access MDB.
      lq


      Paste this function in a module:

      Function ChangeProperty( strPropName As String, varPropType As Variant,
      varPropValue As Variant) As Integer
      On Error GoTo Change_Err

      Dim db As Database, prp As Property
      Const conPropNotFound Error = 3270
      Set db = CurrentDb()
      db.Properties(s trPropName) = varPropValue
      ChangeProperty = True

      Change_Bye:
      On Error Resume Next
      '>clean up object references:
      db.Close
      Set db = Nothing
      Exit Function
      Change_Err:
      If Err = conPropNotFound Error Then '>property not found:
      Set prp = db.CreateProper ty(strPropName, varPropType,
      varPropValue)
      db.Properties.A ppend prp
      Resume Next
      Else '>unknown error:
      ChangeProperty = False
      Resume Change_Bye
      End If
      End Function


      Put this code in your macro:
      =ChangeProperty ("AllowBypassKe y", dbBoolean, False)

      OR

      Put this code in another function or sub:
      CALL ChangeProperty( "AllowBypassKey ", dbBoolean, False)

      Comment

      Working...