can't disable shift key with faq_DisableShiftKeyBypass function

  • Thread starter Thread starter jaworski_m
  • Start date Start date
J

jaworski_m

hello,
I use the function "faq_DisableShiftKeyBypass " described in "SECFAQ.doc" by
Microsoft.

I am logged in as database owner (also a memer of Admins group), have full
permissions. Database is secured, database name isn't misspelled when calling
the function, path to database is correct.

When calling the function I get the error message "Function
DisableShiftKeyBypass did not complete successfully", which means the
property was not created.

However, when I use the function to disable a different (also secured)
database it works as it should.

What might be the problem?

Thank you for hints.
 
Chris, thank you for reply.

I posted the code of the "faq_DisableShiftKeyBypass" (below) for reference
of discussion.
That function fails ... if you're not joined to the secure workgroup when running
the function.
I executed the function from inside the secured database just to make sure
if I am connected to the correct workgroup. It didn't work.
I'd suggest stepping through the function in the debug window to see which line of > code fails and sends you to the error handler.
I did according to your suggestions. The error is triggered in the line
marked said:
That function fails if the db is already opened exclusively.
After your suggestions I tried opening the database exclusively. Function
WORKED.
Running the "faq_DisableShiftKeyBypass" function from SEPARATE
*ShiftByPass.mdb* file (containing module with the function) WORKED ONLY when
this separate file was also opened exclusively.

Correct me if I'm wrong. Does this function execute ONLY when a database is
opened exclusively?

**** CODE START (faq_DisableShiftKeyBypass) ****
Function faq_DisableShiftKeyBypass(strDBName As String, fAllow As Boolean)
As Boolean

On Error GoTo errDisableShift

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

Set ws = DBEngine.Workspaces(0)
<BREAKPOINT> Set db = ws.OpenDatabase(strDBName)

db.Properties("AllowByPassKey") = Not fAllow
faq_DisableShiftKeyBypass = fAllow
exitDisableShift:
Exit Function

errDisableShift:
'The AllowBypassKey property is a user-defined
' property of the database that must be created
' before it can be set. This error code will execute
' the first time this function is run in a database.

If Err = conPropNotFound Then
' You must set the fourth DDL parameter to True
' to ensure that only administrators
' can modify it later. If it was created wrongly, then
' delete it and re-create it correctly.
Set prop = db.CreateProperty("AllowByPassKey", _
dbBoolean, False, True)
db.Properties.Append prop
Resume
Else
MsgBox "Function DisableShiftKeyBypass did not complete successfully."
faq_DisableShiftKeyBypass = False
GoTo exitDisableShift
End If
End Function
**** CODE END ****
 
Back
Top