Disable/Enable the Shift Bypass Key

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--
 
A

Albert D. Kallal

ryguy7272 said:
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

The above does not look correct, lets delete that button start over

let's place a button on the form.

View the buttons property sheet, and select the events tab.

click on the "on click" event, and then click on the [...] button that
appears on the right side. .

Now, choose Code builder

You should be in the code editor, and simply type in:


eg:

SetProperties "AllowBypassKey", dbBoolean, True

So, you only need the one line of code.

When you click on this button the above code will allow (enable) the shift
key.

Let's place another of button on the form, and let's call this button the
disable button. The code behind that button (using the above same process)
will be as follows

SetProperties "AllowBypassKey", dbBoolean, False


The other piece of code can and should be put in a standard code module (and
by the information you've provided in the other post, it looks like you have
that part done correct). It is not clear why there's all this additional
stuff about password stuff in that article. For the time being I would
simply just get the two buttons working and tested out.
 
R

ryguy7272

Thanks for the advice Albert!! I ready your message, changed a few things in
my code, and it worked!!


Regards,
Ryan---
--
RyGuy


Albert D. Kallal said:
ryguy7272 said:
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

The above does not look correct, lets delete that button start over

let's place a button on the form.

View the buttons property sheet, and select the events tab.

click on the "on click" event, and then click on the [...] button that
appears on the right side. .

Now, choose Code builder

You should be in the code editor, and simply type in:


eg:

SetProperties "AllowBypassKey", dbBoolean, True

So, you only need the one line of code.

When you click on this button the above code will allow (enable) the shift
key.

Let's place another of button on the form, and let's call this button the
disable button. The code behind that button (using the above same process)
will be as follows

SetProperties "AllowBypassKey", dbBoolean, False


The other piece of code can and should be put in a standard code module (and
by the information you've provided in the other post, it looks like you have
that part done correct). It is not clear why there's all this additional
stuff about password stuff in that article. For the time being I would
simply just get the two buttons working and tested out.
 
K

Kim M.

Albert,
Thanks, I used this code too and it worked great. I have another question
for you. I'd like to have some kind of visual flag for myself on the form
indicating whether the allowbypass is enabled or disabled. How do I test for
the status of this property?
Thanks!
Kim M.

Albert D. Kallal said:
ryguy7272 said:
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

The above does not look correct, lets delete that button start over

let's place a button on the form.

View the buttons property sheet, and select the events tab.

click on the "on click" event, and then click on the [...] button that
appears on the right side. .

Now, choose Code builder

You should be in the code editor, and simply type in:


eg:

SetProperties "AllowBypassKey", dbBoolean, True

So, you only need the one line of code.

When you click on this button the above code will allow (enable) the shift
key.

Let's place another of button on the form, and let's call this button the
disable button. The code behind that button (using the above same process)
will be as follows

SetProperties "AllowBypassKey", dbBoolean, False


The other piece of code can and should be put in a standard code module (and
by the information you've provided in the other post, it looks like you have
that part done correct). It is not clear why there's all this additional
stuff about password stuff in that article. For the time being I would
simply just get the two buttons working and tested out.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Top