Read-Only Limit

  • Thread starter Thread starter A Moloney
  • Start date Start date
A

A Moloney

Hi
I have a text box on my form that displays the selected
date from a calender. Is there any way that if the
displayed date is within (+/-) 7 days of todays date that
a password prompt is displayed, one permission is full
access and the other would be read-only?

If this is not possible can i just automatically open the
required record in read-only for everyone?

Any help/alternatives appreciated.
 
You could use the Current event to run code that locks all controls for that
record if the date value in the textbox is within your desired range. You
also could use this event to ask for a password as you suggest.
 
Code would be something like this:

Private Sub Form_Current()
Dim blnLockControl As Boolean, blnPass As Boolean
Dim strPass As String
blnLockControl = (Abs(DateDiff("d", Me.txtDate.Value, Date())) <=7)
If blnLockControl = True Then
strPass = InputBox("Enter password:")
blnPass = (strPass <> "Password")
Me.NameOfAControl.Locked = (blnLockControl Or blnPass)
Me.NameOfAnotherControl.Locked = (blnLockControl Or blnPass)
' etc.
End If
End Sub
 
Note that this code is not considered as a "secure" way to test a password.
Better to store the password in a table and then use DLookup function to
retrieve the password for comparison. Even more secure is to use built-in
security that ACCESS contains.. but this may be overkill for what you want
to do here.
--

Ken Snell
<MS ACCESS MVP>
 
Back
Top