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

Shift+Enter to open DB...

Status
Not open for further replies.

netcert

Programmer
Apr 11, 2001
115
US
We have an Access 97 db that users can get to our tables, queries, etc., "behind the scenes" by just hold the Shift key down and pressing Enter. We don't won't to allow this.

If they click on the link that we setup on their desktop the normal way, it opens directly into an Access form which is ok. The problem lies if they do the other and hold the shift key down and do that method.

Any ideas on how to prevent just certain users from doing this?

Rob
 
Nick,

Thanks for the help. One more detail. Can you do this but do it based on which user is trying to open it? For instance, I'd want to still be able to open DB that way for tech. support reasons but wouldn't want the general user to.

Is that possible?

Rob
 
Rob,

Is your Db secured? If it is this is what i do. I have a button on the Main Menu which is only visible to administrators. By default the db will be locked(ie shift key disabled). When they (admin) click this button the enable shift key is called and the db closes. The admin can then open db holding down shift key so he/she can make changes. But on the exit button that users see, I have the disable shift key called.
I have some really cool code which I can send if you want. Just let me know your email address because there is quite a lot of it. It's 11:30 here so i am off to bed now, but i can send it you tomorrow though.

Nick
 
Nick,

That would be great. Send it to rfleming@isa.org

Thanks again.

Rob
 
Rob, another way to do this is using a startup option. The following function looks for /cmd "word" as a startup option on the shortcut. There are two words set - one to disable the Shift key, and one to enable it. Your AutoExec macro needs to call this function prior to doing anything else. In your macro, if CheckCommandLine = True, quit Access.

To disable the Shift key, your administrators create a shortcut to your database followed by /cmd "lock". To enable the Shift key again, you replace this with /cmd "debug".

If you secure your database properly, you may also want to test for the "Admin" user. Once you've demoted this to basic user level, it usually indicates that someone has tried to open the database bypassing the security. Your routine could quit the database if the Admin user attempts to open it, rather than a valid user from the workgroup file.


Function CheckCommandLine() as Boolean
Dim dbs As Database
Dim prp As Property
Dim ysnValue As Boolean
Dim strProperty As String
Dim strMessage As String
Const conPropNotFoundError = 3270


CheckCommandLine = False

' Check value returned by Command function.
' Create property if it doesn't exist

Set dbs = CurrentDb
strProperty = "AllowBypassKey"
On Error GoTo Change_Err

Select Case UCase(Command)
Case "DEBUG"
ysnValue = True
strMessage = "Database is now unlocked. Remove the '/cmd' option from the " & _
"startup line and launch the database again."

Case "LOCK"
ysnValue = False
strMessage = "Database is now locked. Remove the '/cmd' option from the " & _
"startup line and launch the database again."

Case Else
GoTo Change_Bye
End Select

CheckCommandLine = True
dbs.Properties(strProperty) = ysnValue
MsgBox strMessage, vbInformation


Change_Bye:
Exit Function

Change_Err:
' Property not found.
If Err = conPropNotFoundError Then
Set prp = dbs.CreateProperty(strProperty, dbBoolean, ysnValue)
dbs.Properties.Append prp
Resume Next
End If
End Function
 
NetCert, I also wrote a faq to cover this subject. I disabled the shift key on my databases and then discovered my users getting into the design through other methods that I didn't know about. This faq covers all the backdoors that I currently know about.

faq181-1021

Maq B-)
<insert witty signature here>
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top