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!

AllowByPass

Status
Not open for further replies.

childrenfirst

Technical User
Oct 15, 2006
80
US
Hi,

I set up the Startup in Access Project so that users cannot get to the database and tables. However, I would also like to set up AllowByPass so that users cannot bypass Startup. I found some codes in Access Help and the Internet, but I have no idea how and where to add it to my application and how and where to call the function. In Access Help, it said to add the code to AccessObjectProperties using Add Method. It sounds like a mystery to me. Can anyone explain to me step by step how to implement the code in Access Project? Thank you!

Code found in Access Help:

Sub SetBypassProperty()
Const DB_Boolean As Long = 1
ChangeProperty "AllowBypassKey", DB_Boolean, False
End Sub

Function ChangeProperty(strPropName As String, varPropType As Variant, varPropValue As Variant) As Integer
Dim dbs As Object, prp As Variant
Const conPropNotFoundError = 3270

Set dbs = CurrentDb
On Error GoTo Change_Err
dbs.Properties(strPropName) = varPropValue
ChangeProperty = True

Change_Bye:
Exit Function

Change_Err:
If Err = conPropNotFoundError Then ' Property not found.
Set prp = dbs.CreateProperty(strPropName, _
varPropType, varPropValue)
dbs.Properties.Append prp
Resume Next
Else
' Unknown error.
ChangeProperty = False
Resume Change_Bye
End If
End Function

 
You may simply use this 2 functions:

Function DisableByPassKeyADP()
CurrentProject.Properties.Add "AllowByPassKey", False
End Function

Function ReEnableByPassKeyADP()
CurrentProject.Properties.Remove "AllowByPassKey"
End Function

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Hi PH,

Thank you for the suggestion! I would love to try the two functions you suggested, but I am not sure where to store them. Should I save them in a separate module? When and how do I call these two functions?

Right now, I hold shift when launching the application, but if I have the AllowByPass set to false, how do I re-enable AllowByPass when launching the application (do I press a certain key)?

Sorry for asking the silly questions, but I don't know how to handle functions like these.

Thank you!

 
One way is to have an hidden button in a well known position calling the ReEnableByPassKeyADP function.

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Hi PHV,

Thank you for the great idea on hidden button. I have added it and set the command button to call the reenablebypasskey function on click.

The problem now is how will the disablebypasskey function be called when the application is launched?

Thank you for your patience!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top