473,387 Members | 3,820 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

disable/enable the shift key

1
Hi all,
First of all I'd like to thank you very very much ,as finally after many years of searching,I could find a code to disable/enable the shift key,but actually i cannot use the code as I'm very new to VBA,i tried to follow the instructions reported in the code,but i got no result,i still can use the shift key,can you explain in details how to use it correctly to enable/disable users from pressing shift key to view database windw?,the code i was talking about is the below
one:

'This code was originally written by Michael Kaplan.
'It is not to be altered or distributed,
'except as part of an application.
'You are free to use it in any application,
'provided the copyright notice is left unchanged.
'
'Code Courtesy of
'Michael Kaplan
'
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
' *********** Code End ***********

Paste the above code into a module. Then you can use the following
procedures to disable and enable the shift key for when you need it.

Public Sub DisableShiftKey()
If ChangePropertyDdl("AllowBypassKey", dbBoolean, False) Then
MsgBox "Shift key access disabled."
Else
Msgbox "An error occured."
End If
End Sub

Public Sub EnableShiftKey()
If ChangePropertyDdl("AllowBypassKey", dbBoolean, True) Then
MsgBox "Shift key access enabled."
Else
Msgbox "An error occured."
End If
End Sub

One problem I note in my version of Access 2003. The error number for
property not in collection seems to be 3265 now, not 3270. If you get
the an error occured message, change the line:

Const conPropNotFoundError = 3270
to
Const conPropNotFoundError = 3265

This code will disable the shift key for everyone, including you. Make
sure that you put a button or give your self some way to run the enable
code even if you don't have access to the database window. Here's how
I do it.

On a form in the database, I almost always have some sort of
administration functions. I put two buttons on there, one for
disabling and one for enabling the shift key. If I am using user-level
security, I just restrict access to that form to only admins.
Otherwise, you can write a simple piece of code to force a password
prompt on the two buttons.

Private Sub cmdDisableShift_Click()
If MsgBox("Do you want to disable the shift key?", vbYesNo,
"Confirm") = vbYes Then
If InputBox("Password:", "Restricted") = "1234" Then
DisableShiftKey
Else
MsgBox "Incorrect password."
End If
Else
MsgBox "Shift key access is not disabled."
End If
End Sub

Private Sub cmdEnableShift_Click()
If MsgBox("Do you want to enable the shift key?", vbYesNo,
"Confirm") = vbYes Then
If InputBox("Password:", "Restricted") = "1234" Then
EnableShiftKey
Else
MsgBox "Incorrect password."
End If
Else
MsgBox "Shift key access is not enabled."
End If
End Sub

Just replace 1234 with whatever password you want to use.
Jul 25 '07 #1
3 11585
missinglinq
3,532 Expert 2GB
I have to tell you that disabling the <Shift> key is fraught with peril! Think of all the things you can't do! You couldn't even enter an uppercase character in a textbox! What is the key combination you're trying to prevent? <Shift> + ???
You talk of "enable/disable users from pressing shift key to view database window" but pressing F11 brings up the database window.

Linq ;0)>
Jul 26 '07 #2
I think what is trying to be done is stop a user holding down the shift key when they are starting up the database so as to restrict access to the database structure (modify tables, design forms, etc). basically a security feature without having to use the jet database security.

I would also be intrested in this solution as at the moment i am using /runtime on the end of a shortcut to the database. as shown below.

"C:\Program Files\Microsoft Office\OFFICE11\MSACCESS.EXE" "Drive:Path\My Database.mdb" /runtime
This works to some extent but most people would be able to get round this if they look at the properties of the shortcut and remove the /runtime from the end
Jul 26 '07 #3
hyperpau
184 Expert 100+
why don't you just create an MDE file then?
Jul 26 '07 #4

Sign in to post your reply or Sign up for a free account.

Similar topics

7
by: PerryC | last post by:
I have search googles and there are hundreds of tips about AllowByPassKey... however, none works for me... well, perhaps I am too new to such high level functionality that it just does not make...
4
by: Paul T. RONG | last post by:
Dear All, I add two new tables to the database and then the disable shift key codes don't work. These two new tables are actually created by two queries, and only these two are in the front end,...
1
by: simonmarkjones | last post by:
Hi i'm trying to disable the shift key from allowing users to access the design view. I've done a search in groups and know i need to somehow do AllowBypassKey. Everywhere i look there is code...
0
by: talal | last post by:
How to check whether javascript is enable or disable in client browser. Remeber i can check wheter browser client support javascript with BrowserCapability class. But what if the client has disable...
2
by: PamelaDV | last post by:
I am wondering if there is a way to disable the "X" used to close the Access application window? I know how to disable it for individual forms, but I would like to disable it for the application...
4
by: Phoe6 | last post by:
Hi all, I am trying to disable the NIC card (and other cards) enabled in my machine to test diagnostics on that card. I am trying to disable it programmatic using python. I checked python wmi and...
3
by: CanuckChuck | last post by:
I have a code for enabling a command button to password protect the enabling/disabling of the Shift bypass. For some reason though I keep recieving a syntax error when I try to use it. I copied the...
8
by: sebouh181 | last post by:
I am writing to registry using javascript. var wsh = new ActiveXObject("WScript.Shell"); var key = "HKLM\\Software\\Neos\\2.0\\LightMode\\my-script"; wsh.RegWrite (key, 1999, "REG_SZ"); when i...
2
by: Naushad | last post by:
Hi all, I am using the countinous form. I want to Enable/Disable the some fields for perticular records as per the following condition when open the form. I have written this code in "On Current...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.