By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
425,526 Members | 2,207 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 425,526 IT Pros & Developers. It's quick & easy.

Disable Shift Key using AllowBypassKey

P: n/a
Help, please!!

I am running MS Access 2000.

I copied code from Michael Kaplan's website (see below) to disable the
shift key for all non-admin users. I pasted the code into a new
function. I then created a macro, used the Run Code command and
selected my function. When I select the function in the Expression
Builder, it appears as:

ChangePropertyDdl («stPropName», «PropType», «vPropVal»), and I
filled in the values:

ChangePropertyDdl (AllowBypassKey, DB_Boolean, False).

When I run the macro, I get "MS Access cannot find the name
AllowBypassKey you entered in the expression".

I'm new to VBA, and I'm not sure where to go from here. Any assistance
greatly appreciated.

Thanks in advance,
Mark

Code I used:
' *********** Code Start ***********
Function ChangePropertyDdl(stPropName As String, _
PropType As DAO.DataTypeEnum, vPropVal As Variant) _
As Boolean
' Uses the DDL argument to create a property
' that only Admins can change.
'
' Current CreateProperty listing in Access help
' is flawed in that anyone who can open the db
' can reset properties, such as AllowBypassKey
'
On Error GoTo ChangePropertyDdl_Err
Dim db As DAO.Database
Dim prp As DAO.Property
Const conPropNotFoundError = 3270
Set db = CurrentDb
' Assuming the current property was created without
' using the DDL argument. Delete it so we can
' recreate it properly
db.Properties.Delete stPropName
Set prp = db.CreateProperty(stPropName, _
PropType, vPropVal, True)
db.Properties.Append prp
' If we made it this far, it worked!
ChangePropertyDdl = True
ChangePropertyDdl_Exit:
Set prp = Nothing
Set db = Nothing
Exit Function
ChangePropertyDdl_Err:
If Err.Number = conPropNotFoundError Then
' We can ignore when the prop does not exist
Resume Next
End If
Resume ChangePropertyDdl_Exit
End Function

Nov 13 '05 #1
Share this Question
Share on Google+
7 Replies


P: n/a
Stab i nthe dark but:

ChangePropertyDdl ("AllowBypassKey", DB_Boolean, False).

--
This sig left intentionally blank
Nov 13 '05 #2

P: n/a
Tried that and got:

"MS Access cannot find the name
AllowBypassKey you entered in the expression".

Nov 13 '05 #3

P: n/a
You could download my working example here:

http://www.members.shaw.ca/AlbertKal.../msaccess.html

The above lets your browse to the mdb file of your choice, and then set, or
un-set the shift key.
--
Albert D. Kallal (Access MVP)
Edmonton, Alberta Canada
pl*****************@msn.com
http://www.attcanada.net/~kallal.msn
Nov 13 '05 #4

P: n/a
Mark wrote:
Tried that and got:

"MS Access cannot find the name
AllowBypassKey you entered in the expression".


Sure you put the quotes around "AllowBypassKey"?

I just tried it (A2K2) and got no error.

--
This sig left intentionally blank
Nov 13 '05 #5

P: n/a
Ok...added the quotes. :-) I got the same error mesage, so I added
quotes around "DB_Boolean" as well, and then I got "Type Mismatch".
Could it be because I'm in Access 2000 instead of 2002?

Nov 13 '05 #6

P: n/a
That's DAO code: have you set a reference to the Microsoft DAO 3.6 Object
Library? (neither Access 2000 nor 2002 have the reference set by default)

While in the VB Editor, select Tools | References, scroll through the list
of available references until you find the DAO reference, select it and back
out of the dialog.

You needs quotes around the property name, but not around DB_Boolean (which
could also be dbBoolean, or the value of those intrinsic constants, 1).

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)

"Mark" <at*****@yahoo.com> wrote in message
news:11**********************@c13g2000cwb.googlegr oups.com...
Ok...added the quotes. :-) I got the same error mesage, so I added
quotes around "DB_Boolean" as well, and then I got "Type Mismatch".
Could it be because I'm in Access 2000 instead of 2002?

Nov 13 '05 #7

P: n/a
Douglas J. Steele wrote:
That's DAO code: have you set a reference to the Microsoft DAO 3.6 Object
Library? (neither Access 2000 nor 2002 have the reference set by default)

While in the VB Editor, select Tools | References, scroll through the list
of available references until you find the DAO reference, select it and back
out of the dialog.

You needs quotes around the property name, but not around DB_Boolean (which
could also be dbBoolean, or the value of those intrinsic constants, 1).


Is a good point but the code has DAO. prefixes, I would think that it
wouldn't compile at all if DAO wasn't referenced. Maybe version
dependant though so if Mark had DAO 3.5 referenced instead...

--
This sig left intentionally blank
Nov 13 '05 #8

This discussion thread is closed

Replies have been disabled for this discussion.