Opening codes

  • Thread starter Thread starter Deanna
  • Start date Start date
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!!
 
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)??
 
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.
 
<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>
 
Back
Top