Setting AllowBypassKey Property in Access 2000

J

Jim Bonacorda

I am attempting to set the AllowBypassKey property to
false in an mde file, but it does not seem to work. Any
advice is appreciated.

Below is the code I am using:

Sub KeepEmOut()
On Error GoTo SubErr
Const INVALID_PROPERTY_REFERENCE As Integer = 2455
Const ITEM_NOT_FOUND As Integer = 3265
Const PROPERTY_NOT_FOUND As Integer = 3270

Dim dbs As dao.Database
Dim Prpty As dao.Property
Dim strErrMsg, strMsg As String
Set dbs = CurrentDb

' delete property if it exists
dbs.Properties.Delete "AllowBypassKey"
' re-create property,
Set Prpty = dbs.CreateProperty("AllowBypassKey", 1,
False, True)
dbs.Properties.Append Prpty
dbs.Properties.Refresh

SubExit:
Exit Sub

SubErr:
If Err.Number = 3265 Or Err.Number = 3270 Or
Err.Number = 2455 Then
' we can ignore when the prop does not exist
Resume Next
Else
strErrMsg = "Error # " & Err.Number & Chr(13) &
Err.Description
MsgBox strErrMsg, vbCritical, "ERROR"
Resume SubExit
End If
End Sub


Regards,
Jim Bonacorda
 
G

Graham Mandeno

Hi Jim

It would help if you told us what happens when you run your code. Does it
give any indication of failing? Does it ever get to SubErr? If so, from
which line and with what error value? After you run the code, type:
?CurrentDb.properties("AllowBypassKey")
in the debug window. What do you see?
 
T

TC

Suggestions already posted elsewhere.

Jim, please don't MULTI-POST: particularly under slightly different subject
lines! This is guaranteed to reduce our chance of getting help in future.

Multi-postinmg is where you post the same question seperately to different
newsgroups. When you multi-post, the people reading one newsgroup, can not
see any answers that you got in other newsgroups. People can easily waste
their time by answering you in one newsgroup, not knowing that other people
have already answered you in >other< newsgroups.

Instead, CROSS-post. This is where you send the same message >once<, to
several newsgroups, simultaneously. You do this by including >all< the
relevant newsgroup names, in the Newsgroups line of your newsreader,
seperated by semi-colons (or whatever). Then, all of the answers that are
given in one newsgroup - say this one - are instantly visible in all of the
other groups to which you cross-posted. This is much more valuable to the
general readership of the newsgroups, & also more considerate of the people
who take time to answer.

Cheers,
TC
 
G

Guest

TC,

My apologies, I will not multi-post in the future. Thanks
for your response in the other newsgroup.

Regards,
Jim Bonacorda
 
G

Guest

Graham.,

Thanks for your response. The code actually executes with
no errors. What happens is everything looks fine the
first time I open the mde, but thereafter I can use
the 'Shift' key to bypass the startup options. Also, when
I check properties in Tools|Startup menu, every one that I
manually set to False is now True. I found a post on
another newsgroup that worked for me. I call this code
from the FormLoad event of the Startup Form in the mde:

Private Sub SecureMDE()
Dim dbsCurrent As dao.Database
Set dbsCurrent = CurrentDb
' set executable properties.
If InStr(dbsCurrent.Name, "mde") Then
ChangeProperty dbsCurrent, "AllowBreakIntoCode",
dbBoolean, False
ChangeProperty dbsCurrent, "AllowBuiltinToolbars",
dbBoolean, False
' AllowBypassKey commented out until needed.
ChangeProperty dbsCurrent, "AllowBypassKey",
dbBoolean, False
ChangeProperty dbsCurrent, "AllowFullMenus",
dbBoolean, False
ChangeProperty dbsCurrent, "AllowSpecialKeys",
dbBoolean, False
ChangeProperty dbsCurrent, "StartupShowDBWindow",
dbBoolean, False
End If
Set dbsCurrent = Nothing
DoCmd.Restore
End Sub

Private Sub ChangeProperty(dbsCurrent As Database,
strPropertyName As String, _
varPropertyType As Variant, bolPropertyValue As Boolean)
'***************************************
' 11/24/2003 New Code
' Developer: Jim Bonacorda - TEKsystems
' The purpose of this sub is to set
' properties of the 'mde' file (called
' by sub above
'***************************************
On Error GoTo SubErr

dbsCurrent.Properties(strPropertyName) =
bolPropertyValue

SubExit:
Exit Sub

SubErr:
' if property not found, create it
If Err = 3270 Then
Dim prpNew As Property
Set prpNew = dbsCurrent.CreateProperty
(strPropertyName, varPropertyType, _
bolPropertyValue)
dbsCurrent.Properties.Append prpNew
Else
MsgBox Err.Description, vbCritical
End If
End Sub





-----Original Message-----
Hi Jim

It would help if you told us what happens when you run your code. Does it
give any indication of failing? Does it ever get to SubErr? If so, from
which line and with what error value? After you run the code, type:
?CurrentDb.properties("AllowBypassKey")
in the debug window. What do you see?

--
Good Luck!

Graham Mandeno [Access MVP]
Auckland, New Zealand

I am attempting to set the AllowBypassKey property to
false in an mde file, but it does not seem to work. Any
advice is appreciated.

Below is the code I am using:

Sub KeepEmOut()
On Error GoTo SubErr
Const INVALID_PROPERTY_REFERENCE As Integer = 2455
Const ITEM_NOT_FOUND As Integer = 3265
Const PROPERTY_NOT_FOUND As Integer = 3270

Dim dbs As dao.Database
Dim Prpty As dao.Property
Dim strErrMsg, strMsg As String
Set dbs = CurrentDb

' delete property if it exists
dbs.Properties.Delete "AllowBypassKey"
' re-create property,
Set Prpty = dbs.CreateProperty("AllowBypassKey", 1,
False, True)
dbs.Properties.Append Prpty
dbs.Properties.Refresh

SubExit:
Exit Sub

SubErr:
If Err.Number = 3265 Or Err.Number = 3270 Or
Err.Number = 2455 Then
' we can ignore when the prop does not exist
Resume Next
Else
strErrMsg = "Error # " & Err.Number & Chr(13) &
Err.Description
MsgBox strErrMsg, vbCritical, "ERROR"
Resume SubExit
End If
End Sub


Regards,
Jim Bonacorda


.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top