Connecting Tech Pros Worldwide Help | Site Map

Disable Shift Key using AllowBypassKey

Mark
Guest
 
Posts: n/a
#1: Nov 13 '05
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

Trevor Best
Guest
 
Posts: n/a
#2: Nov 13 '05

re: Disable Shift Key using AllowBypassKey


Stab i nthe dark but:

ChangePropertyDdl ("AllowBypassKey", DB_Boolean, False).

--
This sig left intentionally blank
Mark
Guest
 
Posts: n/a
#3: Nov 13 '05

re: Disable Shift Key using AllowBypassKey


Tried that and got:

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

Albert D. Kallal
Guest
 
Posts: n/a
#4: Nov 13 '05

re: Disable Shift Key using AllowBypassKey


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
pleaseNOOSpamKallal@msn.com
http://www.attcanada.net/~kallal.msn


Trevor Best
Guest
 
Posts: n/a
#5: Nov 13 '05

re: Disable Shift Key using AllowBypassKey


Mark wrote:[color=blue]
> Tried that and got:
>
> "MS Access cannot find the name
> AllowBypassKey you entered in the expression".
>[/color]

Sure you put the quotes around "AllowBypassKey"?

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

--
This sig left intentionally blank
Mark
Guest
 
Posts: n/a
#6: Nov 13 '05

re: Disable Shift Key using AllowBypassKey


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?

Douglas J. Steele
Guest
 
Posts: n/a
#7: Nov 13 '05

re: Disable Shift Key using AllowBypassKey


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" <atys222@yahoo.com> wrote in message
news:1105165927.069035.114330@c13g2000cwb.googlegr oups.com...[color=blue]
> 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?
>[/color]


Trevor Best
Guest
 
Posts: n/a
#8: Nov 13 '05

re: Disable Shift Key using AllowBypassKey


Douglas J. Steele wrote:[color=blue]
> 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).
>[/color]

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
Closed Thread