DWB
asked on
Disable Shiftkey Round Two
Access 97:
I found the following example in the Access Help File “AllowBypassKey Property”
I can’t figure out how to use this and/or apply the following example to disable my Shiftkey.
Can anyone please explain how to properly use this example.
************************** *****
The following example shows a procedure named SetStartupProperties that passes the name of the property to be set, its data type, and its desired setting. The general purpose procedure ChangeProperty attempts to set the startup property and, if the property isn't found, uses the CreateProperty method to append it to the Properties collection of the Database object. This is necessary because these properties don't appear in the Properties collection until they've been set or changed at least once.
Sub SetStartupProperties()
ChangeProperty "StartupForm", dbText, "Customers"
ChangeProperty "StartupShowDBWindow", dbBoolean, False
ChangeProperty "StartupShowStatusBar", dbBoolean, False
ChangeProperty "AllowBuiltinToolbars", dbBoolean, False
ChangeProperty "AllowFullMenus", dbBoolean, True
ChangeProperty "AllowBreakIntoCode", dbBoolean, False
ChangeProperty "AllowSpecialKeys", dbBoolean, True
ChangeProperty "AllowBypassKey", dbBoolean, True
End Sub
Function ChangeProperty(strPropName As String, varPropType As Variant, varPropValue As Variant) As Integer
Dim dbs As Database, prp As Property
Const conPropNotFoundError = 3270
Set dbs = CurrentDb
On Error GoTo Change_Err
dbs.Properties(strPropName ) = varPropValue
ChangeProperty = True
Change_Bye:
Exit Function
Change_Err:
If Err = conPropNotFoundError Then ' Property not found.
Set prp = dbs.CreateProperty(strProp Name, _
varPropType, varPropValue)
dbs.Properties.Append prp
Resume Next
Else
' Unknown error.
ChangeProperty = False
Resume Change_Bye
End If
End Function
************************** *****
I found the following example in the Access Help File “AllowBypassKey Property”
I can’t figure out how to use this and/or apply the following example to disable my Shiftkey.
Can anyone please explain how to properly use this example.
**************************
The following example shows a procedure named SetStartupProperties that passes the name of the property to be set, its data type, and its desired setting. The general purpose procedure ChangeProperty attempts to set the startup property and, if the property isn't found, uses the CreateProperty method to append it to the Properties collection of the Database object. This is necessary because these properties don't appear in the Properties collection until they've been set or changed at least once.
Sub SetStartupProperties()
ChangeProperty "StartupForm", dbText, "Customers"
ChangeProperty "StartupShowDBWindow", dbBoolean, False
ChangeProperty "StartupShowStatusBar", dbBoolean, False
ChangeProperty "AllowBuiltinToolbars", dbBoolean, False
ChangeProperty "AllowFullMenus", dbBoolean, True
ChangeProperty "AllowBreakIntoCode", dbBoolean, False
ChangeProperty "AllowSpecialKeys", dbBoolean, True
ChangeProperty "AllowBypassKey", dbBoolean, True
End Sub
Function ChangeProperty(strPropName
Dim dbs As Database, prp As Property
Const conPropNotFoundError = 3270
Set dbs = CurrentDb
On Error GoTo Change_Err
dbs.Properties(strPropName
ChangeProperty = True
Change_Bye:
Exit Function
Change_Err:
If Err = conPropNotFoundError Then ' Property not found.
Set prp = dbs.CreateProperty(strProp
varPropType, varPropValue)
dbs.Properties.Append prp
Resume Next
Else
' Unknown error.
ChangeProperty = False
Resume Change_Bye
End If
End Function
**************************
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
well, where in that code do you want it? Could you explain why you want to use the SetStartupProperty code at all? Do you need some users with the ability to get into the database window, etc., and others don't? If so, then the explanation and example I gave above would seem to suit your needs well.
Sorry, I'm a little late. I posted a comment to this question (very similar to brewdog's, but not as thorough) on the old question. Take a look at the PAQ FYI. brewdog's right on.
good luck as usual...
good luck as usual...
DWB:
The best way to do this is to create another DB and put the code there. You can either run this by a macro or from the debug window. We use this code to disable the bypass keys for all our outgoing apps.
Jim
Function DisableBypass() As Boolean
' Comments : Disable the bypass key (shift) the distribution mdb files
' -------------------------- ---------- ---------- ----------
Dim wrkWksMdb As Workspace
Dim dbsMdb As Database
Dim strLastFunction As String
Dim strCurrentUser As String
strCurrentUser = DBEngine.Workspaces(0).Use rName
If MsgBox("Do you really want to DISABLE bypass keys (Shift)?", _
vbYesNo + vbExclamation + vbDefaultButton2 + vbSystemModal) = vbNo Then
Exit Function
End If
Set wrkWksMdb = CreateWorkspace("wrkWksMdb ", strCurrentUser, "")
Set dbsMdb = wrkWksMdb.OpenDatabase(Pat h & DBName, True) ' Put in the valid path and name for the DB
If DisableByPassKey(dbsMdb) Then
MsgBox "Bypass key (shift) DISABLED!", vbOKOnly + vbExclamation + vbSystemModal
End If
Set dbsMdb = Nothing
Set wrkWksMdb = Nothing
End Function
Function DisableByPassKey(dbsWork As Database) As Boolean
' Comments : Disable the ability to hold down the shift key when running the database.
' -------------------------- ---------- ---------- ----------
On Error GoTo Proc_Err
Dim prpThis As Property
With dbsWork
Set prpThis = .CreateProperty("ALLOWBYPA SSKEY", dbBoolean, False)
.Properties.Delete "ALLOWBYPASSKEY"
.Properties.Append prpThis
End With
Set prpThis = Nothing
DisableByPassKey = True
Exit Function
Proc_Err:
Select Case Err.Number
Case 3265 ' Item not found in this collection.
' ok. it just could not delete the "ALLOWBYPASSKEY" property because it had
' not yet been created. No problem. Just itnore it.
Case Else
' real problem so choke.
DisableByPassKey = False
Application.RunCommand acCmdDebugWindow ' force the debug window open
Debug.Print "Error in DisableByPassKey()", Err.Number, Err.Description
End Select
Resume Next
End Function
The best way to do this is to create another DB and put the code there. You can either run this by a macro or from the debug window. We use this code to disable the bypass keys for all our outgoing apps.
Jim
Function DisableBypass() As Boolean
' Comments : Disable the bypass key (shift) the distribution mdb files
' --------------------------
Dim wrkWksMdb As Workspace
Dim dbsMdb As Database
Dim strLastFunction As String
Dim strCurrentUser As String
strCurrentUser = DBEngine.Workspaces(0).Use
If MsgBox("Do you really want to DISABLE bypass keys (Shift)?", _
vbYesNo + vbExclamation + vbDefaultButton2 + vbSystemModal) = vbNo Then
Exit Function
End If
Set wrkWksMdb = CreateWorkspace("wrkWksMdb
Set dbsMdb = wrkWksMdb.OpenDatabase(Pat
If DisableByPassKey(dbsMdb) Then
MsgBox "Bypass key (shift) DISABLED!", vbOKOnly + vbExclamation + vbSystemModal
End If
Set dbsMdb = Nothing
Set wrkWksMdb = Nothing
End Function
Function DisableByPassKey(dbsWork As Database) As Boolean
' Comments : Disable the ability to hold down the shift key when running the database.
' --------------------------
On Error GoTo Proc_Err
Dim prpThis As Property
With dbsWork
Set prpThis = .CreateProperty("ALLOWBYPA
.Properties.Delete "ALLOWBYPASSKEY"
.Properties.Append prpThis
End With
Set prpThis = Nothing
DisableByPassKey = True
Exit Function
Proc_Err:
Select Case Err.Number
Case 3265 ' Item not found in this collection.
' ok. it just could not delete the "ALLOWBYPASSKEY" property because it had
' not yet been created. No problem. Just itnore it.
Case Else
' real problem so choke.
DisableByPassKey = False
Application.RunCommand acCmdDebugWindow ' force the debug window open
Debug.Print "Error in DisableByPassKey()", Err.Number, Err.Description
End Select
Resume Next
End Function
ASKER
I must apologize for the late response, however, unfortunately every now and again I actually have to perform my real job and make an appearance once or twice at work.
I played around with brewdogs response a bit last night, and I finally got it together. I truly appreciate all the responses, guidance, suggestions, and most importantly everyone’s patience with the novice who tends to bite off more then he can normally chew, thanks for not letting me choke.
If anyone requires any miscellaneous paraphernalia from the Canadian Forces, I’ll try my best to provide, just give me a shout at "dbrydon@webhart.net".
Hope one and all, have a Safe and Rewarding New Year.
Cheers
Dave
I played around with brewdogs response a bit last night, and I finally got it together. I truly appreciate all the responses, guidance, suggestions, and most importantly everyone’s patience with the novice who tends to bite off more then he can normally chew, thanks for not letting me choke.
If anyone requires any miscellaneous paraphernalia from the Canadian Forces, I’ll try my best to provide, just give me a shout at "dbrydon@webhart.net".
Hope one and all, have a Safe and Rewarding New Year.
Cheers
Dave
Great, Dave. Glad I could help out a little.
And don't worry about biting off more than you can chew: I think it's expected of programmers now. :o)
And don't worry about biting off more than you can chew: I think it's expected of programmers now. :o)
Hey people, I tried to implement the code brewdog first talked about...in the access 2000 help... I put it in a module, called it, it doesnt crap out or show an error, but it simply wont work, i cant get any of the properties to change, is there anything else you have to do to make this work?? Any additional libraries to call to or anything?? Thanks guys!
-Adam
-Adam
Adam,
These fixes were done for Access 97. I don't think that they apply to Access 2000. I haven't worked with Access in a while but I think that there are attributes you can set directly in Access 2k that will do this for you.
Jim
These fixes were done for Access 97. I don't think that they apply to Access 2000. I haven't worked with Access in a while but I think that there are attributes you can set directly in Access 2k that will do this for you.
Jim
Jim,
The actual code is taken from the access 2000 help. However, ive tried everything I can think of.... seperate modules, in the open form event, blah blah... it will not change the properties... it doesnt crap out, or cause any errors, in fact it passes right through the code....but nothing happens...really weird....
-Adam
The actual code is taken from the access 2000 help. However, ive tried everything I can think of.... seperate modules, in the open form event, blah blah... it will not change the properties... it doesnt crap out, or cause any errors, in fact it passes right through the code....but nothing happens...really weird....
-Adam
Adam,
I'm busy on some projects at the moment but send me the code you are trying to use and I'll take a look and see what I think is happening. You should know that any code you take from Access 2000 help files may not actually work. I've seen this over and over. However, code snippets that Microsoft supplies are good starting points to write your own code.
Jim
I'm busy on some projects at the moment but send me the code you are trying to use and I'll take a look and see what I think is happening. You should know that any code you take from Access 2000 help files may not actually work. I've seen this over and over. However, code snippets that Microsoft supplies are good starting points to write your own code.
Jim
ASKER
I’ll provide a little background on how I set this up.
I’ve tried several times to create a secure database through Accesses User Group method etc… and have failed miserably. So I currently use the following code in an introductory (Splash Screen) this however is were the Shift Key issue comes into play.
Intro Screen Called “zfrmIntro” which I set for the display form in the Startup Options.
************* Code Starts ****************
' FORM PASSWORD PROTECTED
'-------------------------
' ACTION - Prompt's the user for a password when they open the
' Main Menu form . If the correct password is entered, the
' form is opened. If Not Close and Exit the database.
'-------------------------
Private Sub Form_Open(Cancel As Integer)
Dim strPassword As String
strPassword = InputBox("This form is password-protected. Please enter the correct password below to access the form.", "Password Required")
If strPassword <> "PlacePasswordHere" Then
MsgBox "That is an incorrect password: access has been denied.", vbInformation, "Access Denied"
DoCmd.Quit acExit
End If
End Sub
************* Code Ends ****************