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(strPropName As String, varPropType As Variant,
varPropValue As Variant) As Integer
and I am getting an info box saying:
..."can't find the name 'strPropName'you 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 - 31 Mar 2005 20:30 GMT
A couple of things...
Did you create the property before trying to change it?
Code: (assuming it is an Access Project:
Function AddProp(propName 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
lauren quantrell - 31 Mar 2005 20:38 GMT
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 conPropNotFoundError = 3270
Set db = CurrentDb()
db.Properties(strPropName) = varPropValue
ChangeProperty = True
Change_Bye:
On Error Resume Next
'>clean up object references:
db.Close
Set db = Nothing
Exit Function
Change_Err:
If Err = conPropNotFoundError Then '>property not found:
Set prp = db.CreateProperty(strPropName, varPropType,
varPropValue)
db.Properties.Append prp
Resume Next
Else '>unknown error:
ChangeProperty = False
Resume Change_Bye
End If
End Function
Put this code in your macro:
=ChangeProperty("AllowBypassKey", dbBoolean, False)
OR
Put this code in another function or sub:
CALL ChangeProperty("AllowBypassKey", dbBoolean, False)