wiswalld
asked on
Disable shift key on start up
Disable shift key on startup and prompt for password. I have used the code from the following link but get a syntax error on the msgbox part.
http://www.databasedev.co.uk/disable_shift_bypass.html
http://www.databasedev.co.uk/disable_shift_bypass.html
What is the error and can you paste your exact code ...
mx
mx
which part? paste it here
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
take your pick
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"
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"
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"
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"
ASKER
Compile Error:
Syntax error on the message portions you highlighted.
Syntax error on the message portions you highlighted.
Please post your exact code
mx
mx
The code compiles on my system ...
maybe do this:
A **DeCompile** may help here ...
But first, if you have not already:
Check for any **Missing References via the VBA Editor>>Tools>>References ....
Then, follow this procedure:
0) **Backup your MDB**
1) Compact and Repair
2) Execute the Decompile (See below) >> your database will reopen
3) Close the mdb
4) Open the mdb and do a Compact and Repair from the
5) Open the mdb:
a) Right click over a 'blank' area of the database window (container) and select Visual Basic Editor. A new window will open with the title 'Microsoft Visual Basic' ... followed by then name of your MDB.
b) From the VBA Editor Menu at the top of the window:
>>Debug>>Compile
Note ... after the word Compile ...you will see the name of your 'Project' - just an fyi.
6) Close the mdb
7) Compact and Repair one more time.
*** Executing the DeCompile:
Here is an example of the command line syntax (adjust your path and file name accordingly) for executing the
decompile:
Run this from Start>>Run, enter the following command line ...
"C:\Program Files\Microsoft Office\Office\Msaccess.exe " /decompile
"C:\Access2003Clients\AzDo c\Pgrm\AzD ocPgrm2K3. mdb"
For more detail on the Decompile subject ... visit the Master on the subject (and other great stuff) Michael Kaplan:
http://www.trigeminal.com/usenet/usenet004.asp?1033
mx
maybe do this:
A **DeCompile** may help here ...
But first, if you have not already:
Check for any **Missing References via the VBA Editor>>Tools>>References ....
Then, follow this procedure:
0) **Backup your MDB**
1) Compact and Repair
2) Execute the Decompile (See below) >> your database will reopen
3) Close the mdb
4) Open the mdb and do a Compact and Repair from the
5) Open the mdb:
a) Right click over a 'blank' area of the database window (container) and select Visual Basic Editor. A new window will open with the title 'Microsoft Visual Basic' ... followed by then name of your MDB.
b) From the VBA Editor Menu at the top of the window:
>>Debug>>Compile
Note ... after the word Compile ...you will see the name of your 'Project' - just an fyi.
6) Close the mdb
7) Compact and Repair one more time.
*** Executing the DeCompile:
Here is an example of the command line syntax (adjust your path and file name accordingly) for executing the
decompile:
Run this from Start>>Run, enter the following command line ...
"C:\Program Files\Microsoft Office\Office\Msaccess.exe
"C:\Access2003Clients\AzDo
For more detail on the Decompile subject ... visit the Master on the subject (and other great stuff) Michael Kaplan:
http://www.trigeminal.com/usenet/usenet004.asp?1033
mx
ASKER
Module:
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(strPropN ame, varPropType, varPropValue)
db.Properties.Append prp
Resume Next
Else
SetProperties = False
MsgBox "SetProperties", Err.Number, Err.Description
Resume Exit_SetProperties
End If
End Function
Private Sub bDisableBypassKey_Click()
On Error GoTo Err_bDisableBypassKey_Clic k
'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 = "TypeYourBypassPasswordHer e" 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_Cli ck:
Exit Sub
Err_bDisableBypassKey_Clic k:
MsgBox "bDisableBypassKey_Click", Err.Number, Err.Description
Resume Exit_bDisableBypassKey_Cli ck
End Sub
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)
SetProperties = True
Set db = Nothing
Exit_SetProperties:
Exit Function
Err_SetProperties:
If Err = 3270 Then 'Property not found
Set prp = db.CreateProperty(strPropN
db.Properties.Append prp
Resume Next
Else
SetProperties = False
MsgBox "SetProperties", Err.Number, Err.Description
Resume Exit_SetProperties
End If
End Function
Private Sub bDisableBypassKey_Click()
On Error GoTo Err_bDisableBypassKey_Clic
'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 = "TypeYourBypassPasswordHer
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_Cli
Exit Sub
Err_bDisableBypassKey_Clic
MsgBox "bDisableBypassKey_Click",
Resume Exit_bDisableBypassKey_Cli
End Sub
ASKER
When I compile it hangs on this
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"
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"
ASKER
Followed this:
You might have to set your "References" in the VBA editor to DAO 3.6.
When you are viewing a Module, click the Tools menu » References. Browse for Microsoft DAO 3.6
Select "Files of type: Executable Files (*.exe; *.dll)"
C:\Program Files\Common Files\Microsoft Shared\DAO)
Then explicitly dimension yourcode, i.e. Dim db As DAO.Database, prp As DAO.Property
I get to the part where it opens the DAO file with three things in it. Should I be selecting one?
You might have to set your "References" in the VBA editor to DAO 3.6.
When you are viewing a Module, click the Tools menu » References. Browse for Microsoft DAO 3.6
Select "Files of type: Executable Files (*.exe; *.dll)"
C:\Program Files\Common Files\Microsoft Shared\DAO)
Then explicitly dimension yourcode, i.e. Dim db As DAO.Database, prp As DAO.Property
I get to the part where it opens the DAO file with three things in it. Should I be selecting one?
ASKER
What does this line mean:
Then explicitly dimension yourcode, i.e. Dim db As DAO.Database, prp As DAO.Property
Then explicitly dimension yourcode, i.e. Dim db As DAO.Database, prp As DAO.Property
What does this line mean:
Then explicitly dimension yourcode, i.e. Dim db As DAO.Database, prp As DAO.Property
I means ...instead of doing Dim db As Database, prp As Property
You specifically indicate that you are using DAO ... instead of ADO ...because ... it is possible to use both.
mx
Then explicitly dimension yourcode, i.e. Dim db As DAO.Database, prp As DAO.Property
I means ...instead of doing Dim db As Database, prp As Property
You specifically indicate that you are using DAO ... instead of ADO ...because ... it is possible to use both.
mx
SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
That now compiles ...
mx
mx
both this compiles in here, try copy and paste
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"
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"
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"
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"
ASKER
Same problem here
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"
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"
mx, i posted that already above
fyi
"what does this line mean:
Then explicitly dimension yourcode, i.e. Dim db As DAO.Database, prp As DAO.Property"
If you are only using DAO ... then you do not need to add the DAO prefix ... BUT ... for clarity ... and in case you do add ADO later ... best practice these days is to explicitly include the DAO prefix ... easy to do ... and it will eliminate confusion later.
mx
"what does this line mean:
Then explicitly dimension yourcode, i.e. Dim db As DAO.Database, prp As DAO.Property"
If you are only using DAO ... then you do not need to add the DAO prefix ... BUT ... for clarity ... and in case you do add ADO later ... best practice these days is to explicitly include the DAO prefix ... easy to do ... and it will eliminate confusion later.
mx
wiswalld,
that is not the same as the one i posted....
that is not the same as the one i posted....
ASKER
Sorry Capricorn doing three things at once. The code I posted was the original code from the website. Real stupid question though: what is the passowrd going to be?
cap ... sorry ... I was looking at what he posted ... tested it ... saw the error ... fixed it .. and posted it.
mx
mx
the password is set here
If strInput = "TypeYourBypassPasswordHer e" Then
replace { TypeYourBypassPasswordHere } with your password
If strInput = "TypeYourBypassPasswordHer
replace { TypeYourBypassPasswordHere
ASKER
Thanks
Thank you ..
mx
mx
Sub SetBypassProperty()
Const DB_Boolean As Long = 1
ChangeProperty "AllowBypassKey", DB_Boolean, False
End Sub
Function ChangeProperty(strPropName
Dim dbs As Object, prp As Variant
Const conPropNotFoundError = 3270
Set dbs = dbEngine.Workspaces(0).Ope
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
Then call from the debug window with:
SetBypassProperty
This will turn the shift key bypass off in the MDB. Close this MDB and open the other holding down the shift key. You should get the normal toolbars and the database container.
------------
mx