Opening codes

D

Deanna

Hi,

I have no idea how this works but i know it does!

I want to be able to have a function that; when holding down the shift key
when opening my DB allows me to view design view, but when someone else uses
it (& they don't use the shift key) the DB will allow them to view and edit
data only.

Can anyone help me to 'write' this? or is this simply an option that you
appoint throught a tool bar function???
Pls help!!
 
L

Linq Adams via AccessMonster.com

Goto Tools - Startup

Uncheck the "Display Database Window"

This means the Dialog box where you can click on Forms, Tables, Queries, etc
will not appear, unless you hold down the <Shift> key as you open the db.

If you do this, then obviously you have to use a series of "menu" or
"switchboard" forms to lead your users thru your database, giving them access
to whatever objects you want them to have access to. The initial form needs
to be selected, in this same place, Tools - Startup, in the "Display
Form/Page" box.

This, of course, only supplies limited security. As you've already stated,
holding <Shift> down when opening the database will show the Database Window,
as will pressing <F11> while the database is open. Security here, as most
places, depends on who/what you're trying to protect your database from. This
will work if you simply want to prevent non-Access savvy users from snooping.
 
D

Deanna

Thank you!!! I have everything ready, switchboard & links etc. I would also
like to create an electronic library, do i need to install VB for this or can
i do this through access (2007)??
 
J

Joao

Use this code:

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

On Error GoTo errDisableShift
'This Function will disable the shift at startup causing the Autoexec macro
and startup properties to always be executed
'!!! WARNING !!!This proces is not reversable!!!!!

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("AllowByPassKey") = False

Exit Function

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

'The error-handling routine above starting with the line
'errDisableShift:

'If the AllowByPassKey property doesn't exist - which it doesn't by default
- the routine creates it and sets it to false.

'To enable the shift key to be used again on database startup : The only
difference from ap_DisableShift() is that
'False is changed to True when setting the AllowByPassKey property.
End Function

Remember, before using this code, backup your DB.
 
D

Douglas J. Steele

<picky>
The comment that the process is not reversable is incorrect, especially
given the syntax used for the CreateProperty method. Even when using the
more secure syntax shown in http://www.mvps.org/access/general/gen0040.htm
the process can be reversed by anyone with Admin permissions on the database
</picky>
 
J

Joao

I know Douglas, thanks anyway, but better keep a fresh backup for no
time-consuming.
 
Top