Security for the front end of db

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

What changes need to be made to a front end of an Access database so that a
user can't type in their password, hold down the shift key, and click on OK
so they have access to the tables etc. ?
 
Hi Kerry,

Create the following Function:
'Function sets properties for current database
Public Function SetProperties(strPropName As String, varPropType As Variant,
varPropValue As Variant) As Integer
On Error GoTo Err_SetProperties
Dim db As DAO.Database, prp As DAO.Property
Set db = CurrentDb
db.Properties(strPropName) = varPropValue
SetProperties = True
Set db = Nothing

Exit_SetProperties:
Exit Function

Err_SetProperties:
If Err = 3270 Then 'Property not found
Set prp = db.CreateProperty(strPropName, varPropType, varPropValue)
db.Properties.Append prp
Resume Next
Else
SetProperties = False
MsgBox "SetProperties", Err.Number, Err.Description
Resume Exit_SetProperties
End If
End Function

Call the function in your startup form or module routine:
SetProperties "AllowBypassKey", dbBoolean, False 'Dissallow "SHIFT" to
bypass login
 
Just to clarify, the given code doesn't need to be stored in the database.
It justs needs to be run once and it will take effect the next time you open
the database.

You might want to use the code from
http://www.mvps.org/access/general/gen0040.htm at "The Access Web", though,
if you want to limit who can set that switch back.
 
Emphasizing what Douglas said:

There's really no point putting that code in a startup form or module.

o If you /do not/ run that code /before/ you release the database for
its first use, then, the user can still use the shift-bypass key to
stop that code from running at all. So it does not achieve its purpose.

o Conversely, if you /do/ run that code before you release the
database for its first use, then, the property is already set, & there
is no point setting it again. That will just waste startup time.

IOW, your suggestion implies, to me, that you might not realize that
the property setting does not affect that run, at all. It only affects
the /next/ run - by which time, it is too late!

Personally, I have a small public procedure GOPROD ("go to production")
which sets all the startup properties the way that I want them for
production. As the last step before I release the database, I just go
to the debug window & type GOPROD. I never call that sub again. So that
code does not cause any further overhead.
 
I'm new as far as working with the code part of Access. How would I go about
adding this code to my Access database? Would I create this under the forms
class objects section or the basGeneral module section of the code?

Any help would be greatly appreciated since I'm so new at all this? Thanks
 
Definitely not in the Forms Class Object section. It needs to go into a
module.
 
I'm new with coding so could you tell me how to call the function in the
startup form or module routine? I put the function itself under my module
that is called basGeneral. Do I have the function in the correct place?
 
Back
Top