 |
| Access Discussion of Microsoft Access database design and programming. See also the forums for Access ASP and Access VBA. |
Welcome to the p2p.wrox.com Forums.
You are currently viewing the Access section of the Wrox Programmer to Programmer discussions. This is a community of software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
|
|
|
|

February 14th, 2005, 11:59 AM
|
|
Authorized User
|
|
Join Date: Feb 2005
Posts: 39
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Disable the [SHIFT Key] on Startup
Hi everyone. I would like to disable the [SHIFT] key on startup. Any ideas?
RU1
|
|

February 14th, 2005, 10:00 PM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 1,093
Thanks: 1
Thanked 12 Times in 11 Posts
|
|
Do you want to just flat out disalbe the SHIFT key, or do you want to disable user's ability to use the shift key as a means of bypassing your startup properties and the AutoExec macro?
Assuming you want to the latter, commonly implemented, functionality, you would simply toggle the AllowByPass property. The sub below sets AllowByPass to False, preventing user's from bypassing your startup properties. Set a reference to DAO and call the sub with:
SetByPassKey "AllowBypassKey", dbBoolean, False
(use True to enable the bypass)
Public Sub SetByPassKey(strPropName As String, _
varPropType As Variant, _
varPropValue As Variant)
On Error GoTo Err_SetProperties
Dim db As DAO.Database
Dim prp As DAO.Property
Set db = CurrentDb
db.Properties(strPropName) = varPropValue
Set db = Nothing
Exit_SetProperties:
Exit Sub
Err_SetProperties:
If Err = 3270 Then 'Property not found
Set prp = db.CreateProperty( _
strPropName, varPropType, varPropValue)
db.Properties.Append prp
Resume Next
Else
SetProperties = False
MsgBox "SetProperties", Err.Number, Err.Description
Resume Exit_SetProperties
End If
End Sub
Once you've disabled the bypass key, a convenient way to enable it for administrative purposes is via a password. You can create a form (preferably accessible only by system admins), and place the following in the form module:
Private Sub cmdSetAllowBypassKey_Click()
On Error GoTo Err_cmdSetAllowBypassKey_Click
Dim strInput As String
Dim strMsg As String
Beep
strMsg = "Do you want to enable the Bypass Key?" & vbCrLf & vbLf & _
"Please key password to enable the Bypass Key."
strInput = InputBox(Prompt:=strMsg, Title:="Disable Bypass Key Password")
If strInput = "TypeYourBypassPasswordHere" Then
SetProperties "AllowBypassKey", dbBoolean, True
Beep
MsgBox "The Bypass Key has been enabled." & vbCrLf & vbLf & _
"The Shift key will allow the users to bypass the startup options " & _
"the next time the database is opened.", _
vbInformation, "Set Startup Properties"
Else
Beep
SetProperties "AllowBypassKey", dbBoolean, False
MsgBox "Incorrect ''AllowBypassKey'' Password!" & vbCrLf & vbLf & _
"The Bypass Key was disabled." & vbCrLf & vbLf & _
"The Shift key will NOT allow the users to bypass the startup options " & _
"the next time the database is opened.", _
vbCritical, "Invalid Password"
Exit Sub
End If
Exit_cmdSetAllowBypassKey_Click:
Exit Sub
Err_cmdSetAllowBypassKey_Click:
MsgBox "cmdSetAllowBypassKey_Click", Err.Number, Err.Description
Resume Exit_cmdSetAllowBypassKey_Click
End Sub
Public Function SetProperties(strPropName As String, _
varPropType As Variant, _
varPropValue As Variant) As Integer
On Error GoTo Err_SetProperties
Dim db As DAO.Database
Dim prp As DAO.Property
Set db = CurrentDb
db.Properties(strPropName) = varPropValue
SetProperties = True
Set db = Nothing
Exit_SetProperties:
Exit Function
Err_SetProperties:
If Err = 3270 Then 'Property not found
Set prp = db.CreateProperty( _
strPropName, varPropType, varPropValue)
db.Properties.Append prp
Resume Next
Else
SetProperties = False
MsgBox "SetProperties", Err.Number, Err.Description
Resume Exit_SetProperties
End If
End Function
HTH,
Bob
|
|

February 15th, 2005, 09:15 AM
|
|
Authorized User
|
|
Join Date: Feb 2005
Posts: 39
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
Quote:
quote:Originally posted by Bob Bedell
Do you want to just flat out disalbe the SHIFT key, or do you want to disable user's ability to use the shift key as a means of bypassing your startup properties and the AutoExec macro?
Assuming you want to the latter, commonly implemented, functionality, you would simply toggle the AllowByPass property. The sub below sets AllowByPass to False, preventing user's from bypassing your startup properties. Set a reference to DAO and call the sub with:
SetByPassKey "AllowBypassKey", dbBoolean, False
(use True to enable the bypass)
Public Sub SetByPassKey(strPropName As String, _
varPropType As Variant, _
varPropValue As Variant)
On Error GoTo Err_SetProperties
Dim db As DAO.Database
Dim prp As DAO.Property
Set db = CurrentDb
db.Properties(strPropName) = varPropValue
Set db = Nothing
Exit_SetProperties:
Exit Sub
Err_SetProperties:
If Err = 3270 Then 'Property not found
Set prp = db.CreateProperty( _
strPropName, varPropType, varPropValue)
db.Properties.Append prp
Resume Next
Else
SetProperties = False
MsgBox "SetProperties", Err.Number, Err.Description
Resume Exit_SetProperties
End If
End Sub
Once you've disabled the bypass key, a convenient way to enable it for administrative purposes is via a password. You can create a form (preferably accessible only by system admins), and place the following in the form module:
Private Sub cmdSetAllowBypassKey_Click()
On Error GoTo Err_cmdSetAllowBypassKey_Click
Dim strInput As String
Dim strMsg As String
Beep
strMsg = "Do you want to enable the Bypass Key?" & vbCrLf & vbLf & _
"Please key password to enable the Bypass Key."
strInput = InputBox(Prompt:=strMsg, Title:="Disable Bypass Key Password")
If strInput = "TypeYourBypassPasswordHere" Then
SetProperties "AllowBypassKey", dbBoolean, True
Beep
MsgBox "The Bypass Key has been enabled." & vbCrLf & vbLf & _
"The Shift key will allow the users to bypass the startup options " & _
"the next time the database is opened.", _
vbInformation, "Set Startup Properties"
Else
Beep
SetProperties "AllowBypassKey", dbBoolean, False
MsgBox "Incorrect ''AllowBypassKey'' Password!" & vbCrLf & vbLf & _
"The Bypass Key was disabled." & vbCrLf & vbLf & _
"The Shift key will NOT allow the users to bypass the startup options " & _
"the next time the database is opened.", _
vbCritical, "Invalid Password"
Exit Sub
End If
Exit_cmdSetAllowBypassKey_Click:
Exit Sub
Err_cmdSetAllowBypassKey_Click:
MsgBox "cmdSetAllowBypassKey_Click", Err.Number, Err.Description
Resume Exit_cmdSetAllowBypassKey_Click
End Sub
Public Function SetProperties(strPropName As String, _
varPropType As Variant, _
varPropValue As Variant) As Integer
On Error GoTo Err_SetProperties
Dim db As DAO.Database
Dim prp As DAO.Property
Set db = CurrentDb
db.Properties(strPropName) = varPropValue
SetProperties = True
Set db = Nothing
Exit_SetProperties:
Exit Function
Err_SetProperties:
If Err = 3270 Then 'Property not found
Set prp = db.CreateProperty( _
strPropName, varPropType, varPropValue)
db.Properties.Append prp
Resume Next
Else
SetProperties = False
MsgBox "SetProperties", Err.Number, Err.Description
Resume Exit_SetProperties
End If
End Function
HTH,
Bob
|
|
|

September 16th, 2007, 11:21 AM
|
|
Authorized User
|
|
Join Date: May 2004
Posts: 12
Thanks: 0
Thanked 0 Times in 0 Posts
|
|
When Excution gets to Set db = CurrentDb, it gives me msg
object Required
pls help me ?
|
|

September 22nd, 2007, 09:27 PM
|
|
Friend of Wrox
|
|
Join Date: Jun 2003
Posts: 1,093
Thanks: 1
Thanked 12 Times in 11 Posts
|
|
You need to set a reference to the DAO object library.
|
|
 |