Access

  • Thread starter Thread starter Kevin
  • Start date Start date
K

Kevin

In my access app, I hide all tool bars and use my
customised menu so that users cannot see the tables behind
the scene. However, for advanced users, they know that
they can disable my setting by open the database file with
the shift key pressed down. This will open the database
window instead of running the first form.

Is there anyway to disable this feature in Access?

Many thanks

Kevin
 
also, there's no going back from that, so keep a copy of your db without
that code....
 
actually, there IS going back from that...you just have to
set it up carefully. here's the code i've used the last 4
years, saved in a standard module:

Public Sub SetStartupPropertiesT()

ChangeProperty "AllowBypassKey", dbBoolean, True
MsgBox "The database is UNlocked, when you next open
the application."

End Sub

Public Sub SetStartupPropertiesF()

ChangeProperty "AllowBypassKey", dbBoolean, False
MsgBox "The database is LOCKED, when you next open the
application."

End Sub

Public Function ChangeProperty(strPropName As String,
varPropType As Variant, varPropValue As Variant) As Integer

Dim dbs As Database, prp As Property
Const conPropNotFoundError = 3270

Set dbs = CurrentDb
On Error GoTo Change_Err
dbs.Properties(strPropName) = varPropValue
ChangeProperty = True

change_bye:
Exit Function

Change_Err:
If Err = conPropNotFoundError Then 'prop not found
Set prp = dbs.CreateProperty(strPropName,
varPropType, varPropValue)
dbs.Properties.Append prp
Resume Next
Else
'unkown error
ChangeProperty = False
Resume change_bye
End If

End Function

i create a transparent (and tiny) command button on the
first form that opens when the db opens. i set the On
Click event to SetStartupPropertiesT(), and set the
command button's Caption property to an unusual key
combination - one the user isn't likely to use by accident.
then i can open the db and unlock it anytime i want to.
when i want to re-lock the db, i run procedure
SetStartupPropertiesF() directly from the module window.

i got the ChangeProperty function from the Access Help
file.
 
actually, there IS going back from that...you just have to
set it up carefully. here's the code i've been using the
last 4 years:

Public Sub SetStartupPropertiesT()

ChangeProperty "AllowBypassKey", dbBoolean, True
MsgBox "The database is UNlocked, when you next open
the application."

End Sub

Public Sub SetStartupPropertiesF()

ChangeProperty "AllowBypassKey", dbBoolean, False
MsgBox "The database is LOCKED, when you next open the
application."

End Sub

Public Function ChangeProperty(strPropName As String,
varPropType As Variant, varPropValue As Variant) As Integer

Dim dbs As Database, prp As Property
Const conPropNotFoundError = 3270

Set dbs = CurrentDb
On Error GoTo Change_Err
dbs.Properties(strPropName) = varPropValue
ChangeProperty = True

change_bye:
Exit Function

Change_Err:
If Err = conPropNotFoundError Then 'prop not found
Set prp = dbs.CreateProperty(strPropName,
varPropType, varPropValue)
dbs.Properties.Append prp
Resume Next
Else
'unkown error
ChangeProperty = False
Resume change_bye
End If

End Function

save the above code in a standard module. then open (in
design view) whatever form opens when the db opens. add a
transparent (and tiny) command button to the form, and set
the Tab Stop property to No. call procedure
SetStartupPropertiesT() in the On Click event. set the
Caption property to an unusual key combination, one the
user is not likely to use accidentally. viola, now you can
open and "unlock" the db whenever you want to. make sure
you test the "unlock" before "locking" the db. to lock it,
open the standard module and run procedure
SetStartupPropertiesF() from the module window.

i got the code from Access Help.
(this is a second posting - the first didn't seem to go
thru. if it double-posts, sorry.)
 
Back
Top