Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Disable Shift Key at startup 3

Status
Not open for further replies.

bravid98

Programmer
Jun 6, 2001
7
US
I've been looking for a way to disable to shift key at startup but have been unable to find anything that works. The database in question is in Access 2k. I've looked around on these boards and found a few possible solutions, however none of them seem to work for me. Can anyone give me a hand in getting this to work?
 
Hi!

There are functions for set of start up.

Public NewAllowBypassKey As Variant

Function SetStartupProperties()
ChangeProperty "AppIcon", dbText, "C:\Unt4130\Lat\Kardai.ico"
'Location of Icon
ChangeProperty "StartupForm", dbText, "csb40"
'StartUp form
ChangeProperty "StartupShowDBWindow", dbBoolean, False
ChangeProperty "StartupShowStatusBar", dbBoolean, True 'NewAllowBypassKey
ChangeProperty "AllowBuiltinToolbars", dbBoolean, NewAllowBypassKey
ChangeProperty "AllowFullMenus", dbBoolean, NewAllowBypassKey
ChangeProperty "AllowBreakIntoCode", dbBoolean, NewAllowBypassKey
ChangeProperty "AllowSpecialKeys", dbBoolean, NewAllowBypassKey
ChangeProperty "AllowBypassKey", dbBoolean, NewAllowBypassKey
'Set Allow suspend Start Up with <Shift key> True or False
ChangeProperty &quot;StartUpMenuBar&quot;, dbText, &quot;MyMenuBar&quot;
ChangeProperty &quot;AllowToolbarChanges&quot;, dbBoolean, NewAllowBypassKey
ChangeProperty &quot;AllowShortcutMenus&quot;, dbBoolean, NewAllowBypassKey
ChangeProperty &quot;StartupShortcutMenuBar&quot;, dbBoolean, NewAllowBypassKey
End Function

Function ChangeProperty(strPropName As String, varPropType As Variant, varPropValue As Variant) As Integer
Dim dbs As Database, prp As Property
Const conPropNotFoundError = 3270

Set dbs = CurrentDb
On Error GoTo Change_Err
dbs.Properties(strPropName) = varPropValue
ChangeProperty = True

Change_Bye:
Exit Function

Change_Err:
If Err = conPropNotFoundError Then ' Property not found.
Set prp = dbs.CreateProperty(strPropName, _
varPropType, varPropValue)
dbs.Properties.Append prp
Resume Next
Else
' Unknown error.
ChangeProperty = False
Resume Change_Bye
End If
End Function[/b]

Example:
NewAllowBypassKey = False
call SetStartupProperties

I made special form for set Start Up for Administrator and for other Users using.

I can send you Sample DB wich include this and some other solutions like Users and group accounts from Access application, examples of Common Dialog control using and several other. If you interest write me.

Aivars
alaganovskis@hotmail.com
 
I found the following on the Microsoft web site. I think it is perfect for your problem:

Function DisableShift()
'This function will disable the shift at startup causing
'the Autoexec macro and Startup properties to always be executed

On Error GoTo errDisableShift

Dim db As DAO.Database
Dim prop As Property
Const conPropNotFound = 3270

Set db = CurrentDb()

'This next line disables the shift key on startup.
db.Properties(&quot;AllowByPassKey&quot;) = False

'function successful
Exit Function

errDisableShift:
'The first part of this error routine creates the &quot;AllowByPassKey
'property if it does not exist.
If Err = conPropNotFound Then
Set prop = db.CreateProperty(&quot;AllowByPassKey&quot;, _
dbBoolean, False)
db.Properties.Append prop
Resume Next
Else
MsgBox &quot;Function 'DisableShift' did not complete successfully.&quot;
Exit Function
End If

End Function

Function EnableShift()
'This function will enable the shift key at startup causing
'the Autoexec macro and Startup properties to be bypassed
'if the user holds down the shift key when opening the database.

On Error GoTo errEnableShift

Dim db As Database
Dim prop As Property
Const conPropNotFound = 3270

Set db = CurrentDb()

'This next line disables the shift key on startup.
db.Properties(&quot;AllowByPassKey&quot;) = True

'function successful
Exit Function

errEnableShift:
'The first part of this error routine creates the &quot;AllowByPassKey
'property if it does not exist.
If Err = conPropNotFound Then
Set prop = db.CreateProperty(&quot;AllowByPassKey&quot;, _
dbBoolean, True)
db.Properties.Append prop
Resume Next
Else
MsgBox &quot;Function 'DisableShift' did not complete successfully.&quot;
Exit Function
End If

End Function
 
I tried the solution put forward by 'Webuser' and it worked great - well done. If you are using Access 2k, make sure you prefix the db and property declarations with DAO. (eg Dim prop as property becomes Dim prop as DAO.property), and also add a Microsoft DAO library to your references - I used 3.6.

Richard
(an Access wannabee who can't believe just how much stuff there is to learn!!!)
PS 'Aivars' code looks very useful as well - thanks
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top