Help, please!!
I am running MS Access 2000.
I copied code from Michael Kaplan's website (see below) to disable the
shift key for all non-admin users. I pasted the code into a new
function. I then created a macro, used the Run Code command and
selected my function. When I select the function in the Expression
Builder, it appears as:
ChangePropertyDdl («stPropName», «PropType», «vPropVal»), and I
filled in the values:
ChangePropertyDdl (AllowBypassKey, DB_Boolean, False).
When I run the macro, I get "MS Access cannot find the name
AllowBypassKey you entered in the expression".
I'm new to VBA, and I'm not sure where to go from here. Any assistance
greatly appreciated.
Thanks in advance,
Mark
Code I used:
' *********** Code Start ***********
Function ChangePropertyDdl(stPropName As String, _
PropType As DAO.DataTypeEnum, vPropVal As Variant) _
As Boolean
' Uses the DDL argument to create a property
' that only Admins can change.
'
' Current CreateProperty listing in Access help
' is flawed in that anyone who can open the db
' can reset properties, such as AllowBypassKey
'
On Error GoTo ChangePropertyDdl_Err
Dim db As DAO.Database
Dim prp As DAO.Property
Const conPropNotFoundError = 3270
Set db = CurrentDb
' Assuming the current property was created without
' using the DDL argument. Delete it so we can
' recreate it properly
db.Properties.Delete stPropName
Set prp = db.CreateProperty(stPropName, _
PropType, vPropVal, True)
db.Properties.Append prp
' If we made it this far, it worked!
ChangePropertyDdl = True
ChangePropertyDdl_Exit:
Set prp = Nothing
Set db = Nothing
Exit Function
ChangePropertyDdl_Err:
If Err.Number = conPropNotFoundError Then
' We can ignore when the prop does not exist
Resume Next
End If
Resume ChangePropertyDdl_Exit
End Function