I am trying to lock a database with Changeproperty AllowBypassKey, but this property is not recognized (Access 2000). I saw an existing database in which it worked!
Probably doesn't work because the property does not yet exist in the Db. The first time you use it you need to create the property :
Public Function disable_shift_on_entrance()
Dim prp As Property
Dim dbs As Database
Set dbs = CurrentDb
dbs.Properties("AllowByPassKey" = False
Set prp = dbs.CreateProperty("AllowByPassKey", _
dbBoolean, False)
dbs.Properties.Append prp
End Function
After that, you can use :
dbCurrent.Properties("AllowBypassKey" = True
(or False offcourse)
Just make sure you don't lock yourself out.
"In three words I can sum up everything I've learned about life: it goes on."
- Robert Frost 1874-1963
I handle the Properties.Append in the error handler if the property doesn't exist yet. The message box will tell you what the setting is.
I call this routine from some small label on the double_click event. Then I can set the ByPass on or off quickly and know what the setting is immediately.
[tt]
Private Const PropNotFound As Long = 3270
Public Sub ByPassKeyToggle()
'This Code Disables/Enables the Shift Key
On Error GoTo Error_ByPass
Dim Prp As DAO.Property
Dim db As DAO.Database
Dim blnToggle As Boolean
Set db = CurrentDb()
blnToggle = db.Properties("allowbypasskey"
Thanks for your examples.
Unfortunately it doesn't work :-( . Error message 3270: cannot find property.
The same goes for property AllowBreakIntoCode
Any more suggestions?
I had a similar problem using this code, where access would present a message box basically saying the property already existed in the collection.
after commenting the following line, everything worked well.
db.Properties.Append Prp
Great piece of code guys, and thanks for sharing
I was just wondering though, how do you utliise it? At present i also run the code from the double-click event of a hidden label at the top-left hand corner of the first form shown in the database.
Is there any way to check if another key is pressed at the same time?
Ideally I'd like for this code to only be run if the control key is held down at the same time as double-clicking the hidden label, any ideas?
*You'll notice that this (DaOtH cited above) is the very code that's in the error handler, with the addition of a .Refresh. The advantage is that this can be dropped into a new db and run without manually creating the property; once created the sub won't attempt to recreate it.
Try putting a breakpoint early in the sub and stepping through the routine--see if it drops into the error handler and responds properly to the test for the constant. (Did you make sure that code is set to break only on unhandled errors?)
Finally, I got it working.
I manually created the property first, because none of the code above worked. (error number 0
A reference to MS DAO 3.6 had to be made too.
It bothers me that it should work with an error bypass, but in the end it works.
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.