Hi ,
On a form called PasswordForm form you can protect the ability to enable
disable by usign a password requirements code as follows create a button
called "shift key" and set the click event to
Private Sub shift_key_Click()
On Error GoTo Err_shift_key_Click
Dim stDocName As String
Dim stLinkCriteria As String
Dim message As String
Dim retval
message = "Please Enter Password"
retval = InputBox(Prompt:=message, Title:="Administrator Use Only")
If retval = "yourpassword" Then
stDocName = "ShiftKeyStatus"
DoCmd.OpenForm stDocName, , , stLinkCriteria
Else
MsgBox ("Sorry, that password is incorrect.Please try again.")
End If
Exit_shift_key_Click:
Exit Sub
Err_shift_key_Click:
MsgBox Err.Description
Resume Exit_shift_key_Click
End Sub
Hi Again
Okay Now Create a form called ShiftKeyStatus
Enter the following code
Option Compare Database
Option Explicit
Private Sub Command0_Click()
On Error GoTo Err_Command0_Click
Screen.PreviousControl.SetFocus
DoCmd.FindNext
Exit_Command0_Click:
Exit Sub
Err_Command0_Click:
MsgBox Err.Description
Resume Exit_Command0_Click
End Sub
Private Sub CloseFormShiftKeyStatus_Click()
On Error GoTo Err_CloseFormShiftKeyStatus_Click
DoCmd.Close
Exit_CloseFormShiftKeyStatus_Click:
Exit Sub
Err_CloseFormShiftKeyStatus_Click:
MsgBox Err.Description
Resume Exit_CloseFormShiftKeyStatus_Click
End Sub
'********************************************************
'This Code Disables the Shift Key
'
Private Sub Disable_Shift_Key_Click()
On Error GoTo Err_Disable_Shift_Key_Click
Dim db As Database
Dim prp As Property
Set db = CurrentDb
Set prp = db.CreateProperty("AllowByPassKey", dbBoolean, False)
db.Properties.append prp
Exit_Disable_Shift_Key_Click:
Exit Sub
Err_Disable_Shift_Key_Click:
MsgBox ("Shift Key Has Already Been Disabled")
Resume Exit_Disable_Shift_Key_Click
End Sub
'********************************************************
'********************************************************
'This Code Re-enables the Shift Key
'
Private Sub Enable_Shift_Key_Click()
On Error GoTo Err_Enable_Shift_Key_Click
Dim db As Database
Set db = CurrentDb
db.Properties.Delete "AllowByPassKey"
db.Properties.Refresh
Exit_Enable_Shift_Key_Click:
Exit Sub
Err_Enable_Shift_Key_Click:
MsgBox ("Shift Key Has Already Been Enabled")
Resume Exit_Enable_Shift_Key_Click
End Sub
'********************************************************
Private Sub Form_Open(Cancel As Integer)
Dim stDocName As String
Dim stLinkCriteria As String
stDocName = "PasswordForm"
DoCmd.Close acForm, stDocName
End Sub
This is working for me
Rgds
Nobleman