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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Security in Access 1

Status
Not open for further replies.

DrinkN1

Programmer
Apr 15, 2002
23
US
I have an Access database that is compiled into an .ade project and accesses an SQL Server 2000 database.

The .ade starts with a form, and hides the tables/design window as well as hiding all of the menu/tool bars.

However, when you open an Access file while holding down the Shift key, the startup form/code is skipped, and it opens straight into the databse design screen.

Is there a way to protect a database so that the Shift key bypass does not work?

Thanks!
 
search for "disable bypass" in groups.google.com for the group comp.databases.ms-access. You'll find everything you need there.

Jeremy =============
Jeremy Wallace
AlphaBet City Dataworks

Take a look at the Developers' section of the site for some helpful fundamentals.
 
Thanks for the reply, it was exactly what I needed to point me in the right direction. The answers at google were close, but not 100% matching to my problem. However, they gave me enough info to proceed to find the solution I was looking for.

For those who are interested...

Using an ADE or ADP file requires a bit of different code than the .MDB/MDE files. Call this routine in your startup form and it'll disable the bybass. Then, from there on out, your ADP/ADE file will be protected.

As a side note, I did a toggle switch based on my login to the database that will allow me to enable/disable it at will. Afterall, sometimes I need to get in it!


Sub DisableKey()
Dim bolBypassVal As Boolean

On Error GoTo PropError
bolBypassVal = CurrentProject.Properties("AllowBypassKey")
Exit Sub

PropError:
CurrentProject.Properties.Add "AllowBypassKey", FALSE
Resume Next
End Sub
 
I found the instructions in the knowledge base at microsoft.com. Here is the code. I only changed the database name.

'? faq_DisableShiftKeyBypass("d:\hr\position_master.mde",true)
'Paste above in debug window and press return

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


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top