You use the AllowBypassKey property of the database object to prevent the shift key from bypassing startup. I'm still using Access 97 for most stuff (a lot of DAO code to convert) so I'm not sure if the below code will work seemlessly in later versions. NoByPass sets the property to false using the second function. I think I liberated the second function from somewhere but can't remember where... Must have been an MSKB article. It also uses DAO. I don't know how many more versions will let us keep DAO but until then, this DAO code isn't exactly the performance dog that keeps me from jumping to 2002
Function NoByPass()
Dim varResult As Variant
varResult = AllowBypassKeyFalse
If varResult = True Then
MsgBox "Bypass startup key will now be disregarded."
Else
MsgBox "Unable to disable bypass startup key."
End If
End Function
Function AllowBypassKeyFalse() As Integer
Dim dbs As Database, prp As Property
Dim strPropName As String
Const conPropNotFoundError = 3270
Set dbs = CurrentDb
strPropName = "AllowBypassKey"
On Error GoTo AllowBypassKeyFalse_Err
dbs.Properties(strPropName) = False
AllowBypassKeyFalse = True
AllowBypassKeyFalse_Exit:
Exit Function
AllowBypassKeyFalse_Err:
If Err = conPropNotFoundError Then ' Property not found.
Set prp = dbs.CreateProperty(strPropName, dbBoolean, False)
dbs.Properties.Append prp
Resume Next
Else
' Unknown error.
AllowBypassKeyFalse = False
Resume AllowBypassKeyFalse_Exit
End If
End Function