R
ryguy7272
I am using Access 2007. I tried to utilize the code at this site:
http://www.databasedev.co.uk/disable_shift_bypass.html
I created a control button and associated some code with the button. When I
click the button I get the following message:
‘You didn’t specify the search criteria with a FirdRecord action. In the
Macro window, insert a FindRecord action before the FindNext action.’ I’m
not sure what this means…
Basically, I put a control button on a blank Form and the properties of the
button are as follows:
Name = bDisableBypassKey_Click
I think clicking the button fires the VBA code:
Private Sub bDisableBypassKey_Click()
On Error GoTo Err_bDisableBypassKey_Click
'This ensures the user is the programmer needing to disable the Bypass Key
Dim strInput As String
Dim strMsg As String
Beep
strMsg = "Do you want to enable the Bypass Key?" & vbCrLf & vbLf & _
"Please key the programmer's 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_bDisableBypassKey_Click:
Exit Sub
Err_bDisableBypassKey_Click:
MsgBox "bDisableBypassKey_Click", Err.Number, Err.Description
Resume Exit_bDisableBypassKey_Click
End Sub
I put this code in Module1:
Option Compare Database
Option Explicit
Public Function SetProperties(strPropName As String, _
varPropType As Variant, varPropValue As Variant) As Integer
On Error GoTo Err_SetProperties
Dim db As DAO.Database, 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
I thought I followed the instructions closely, but apparently I missed
something. I have been developing Excel applications, using lots of VBA, for
a few years now. I am fairly new to Access though. I could use a point in
the right direction with this project. What could be wrong? What could
cause this error?
Regards,
Ryan--
http://www.databasedev.co.uk/disable_shift_bypass.html
I created a control button and associated some code with the button. When I
click the button I get the following message:
‘You didn’t specify the search criteria with a FirdRecord action. In the
Macro window, insert a FindRecord action before the FindNext action.’ I’m
not sure what this means…
Basically, I put a control button on a blank Form and the properties of the
button are as follows:
Name = bDisableBypassKey_Click
I think clicking the button fires the VBA code:
Private Sub bDisableBypassKey_Click()
On Error GoTo Err_bDisableBypassKey_Click
'This ensures the user is the programmer needing to disable the Bypass Key
Dim strInput As String
Dim strMsg As String
Beep
strMsg = "Do you want to enable the Bypass Key?" & vbCrLf & vbLf & _
"Please key the programmer's 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_bDisableBypassKey_Click:
Exit Sub
Err_bDisableBypassKey_Click:
MsgBox "bDisableBypassKey_Click", Err.Number, Err.Description
Resume Exit_bDisableBypassKey_Click
End Sub
I put this code in Module1:
Option Compare Database
Option Explicit
Public Function SetProperties(strPropName As String, _
varPropType As Variant, varPropValue As Variant) As Integer
On Error GoTo Err_SetProperties
Dim db As DAO.Database, 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
I thought I followed the instructions closely, but apparently I missed
something. I have been developing Excel applications, using lots of VBA, for
a few years now. I am fairly new to Access though. I could use a point in
the right direction with this project. What could be wrong? What could
cause this error?
Regards,
Ryan--