Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Run-Time Error 3001 with AllowByPassKey sub

Status
Not open for further replies.

TeresePamela

Programmer
Sep 4, 2003
40
US
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
 
Have you tried to replace this:
dbs.Properties.Append.prp
By this ?
dbs.Properties.Append prp


Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ222-2244
 
ahhh.. if it wasn't for syntax I'd be brilliant.

Seriously thanks (again) PH. that was it.

Pam
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top