TeresePamela
Programmer
My Problem:
When running the code below I get the "Run-Time Error 3001 - Invalid Arguement" error message when it reaches the dbs.properties.append.prp line.
This code is a modified version of code that is posted in this forum.
I'm using Access 2000 and just testing this so I have it attached to the click event of a form created strictly for this test.
What I'm trying to do:
My goal is to completely lock out the form and have code in the opening of the form which checks Environ(username) to see if it's me, if it is a messagebox will ask me if I want to open in development mode or not, If I say yes I plan to have the code to delete the AllowByPassKey property run at this point, I can then click the LockOut button to re-secure when I'm done.
Can anyone tell me how to get the code to run properly and/or does anyone have any input as to my goals?? (I realize I'm in dangerous territory with this one).
Thanks in advance for any and all input,
Pam
Public Sub Command0_Click()
Dim dbs As Object
Dim prp As Object
Const PROPERTY_NOT_FOUND As Integer = 3270
On Error GoTo ErrorHandler
Set dbs = Application.CurrentDb
dbs.Properties("AllowByPassKey") = False ' If fails, property doesn't exist.
ExitLine:
dbs.Close
Set dbs = Nothing
Set prp = Nothing
Exit Sub
ErrorHandler:
If Err.Number = PROPERTY_NOT_FOUND Then
MsgBox "AllowByPassKey not found - going to create and set to False now"
Set prp = dbs.CreateProperty("AllowByPassKey", dbBoolean, False)
dbs.Properties.Append.prp
Resume Next
Else
Resume ExitLine
End If
When running the code below I get the "Run-Time Error 3001 - Invalid Arguement" error message when it reaches the dbs.properties.append.prp line.
This code is a modified version of code that is posted in this forum.
I'm using Access 2000 and just testing this so I have it attached to the click event of a form created strictly for this test.
What I'm trying to do:
My goal is to completely lock out the form and have code in the opening of the form which checks Environ(username) to see if it's me, if it is a messagebox will ask me if I want to open in development mode or not, If I say yes I plan to have the code to delete the AllowByPassKey property run at this point, I can then click the LockOut button to re-secure when I'm done.
Can anyone tell me how to get the code to run properly and/or does anyone have any input as to my goals?? (I realize I'm in dangerous territory with this one).
Thanks in advance for any and all input,
Pam
Public Sub Command0_Click()
Dim dbs As Object
Dim prp As Object
Const PROPERTY_NOT_FOUND As Integer = 3270
On Error GoTo ErrorHandler
Set dbs = Application.CurrentDb
dbs.Properties("AllowByPassKey") = False ' If fails, property doesn't exist.
ExitLine:
dbs.Close
Set dbs = Nothing
Set prp = Nothing
Exit Sub
ErrorHandler:
If Err.Number = PROPERTY_NOT_FOUND Then
MsgBox "AllowByPassKey not found - going to create and set to False now"
Set prp = dbs.CreateProperty("AllowByPassKey", dbBoolean, False)
dbs.Properties.Append.prp
Resume Next
Else
Resume ExitLine
End If