read-only

  • Thread starter Thread starter K Crofts
  • Start date Start date
K

K Crofts

Hi
Mt records are defined by the date entered by the user.
Is there any way that the form can prompt for a password
(with read-only option) when a user selects a date
between 7 days of todays date? I have a calender control
and a text box that contains the specified date in it
also.
Please note, i am new to access so do not even know if
this is possible. Any help or alternative would be
greatfully received.
 
Hi
Mt records are defined by the date entered by the user.
Is there any way that the form can prompt for a password
(with read-only option) when a user selects a date
between 7 days of todays date? I have a calender control
and a text box that contains the specified date in it
also.
Please note, i am new to access so do not even know if
this is possible. Any help or alternative would be
greatfully received.

It's possible; it would take some VBA code, a utility table containing
a field named Password, and an Form frmPassword with an unbound
textbox txtPassword on it. Set its Input Mask property to "Password"
and its Visible property to False. Sample air code:

Private Sub txtDate_BeforeUpdate(Cancel as Integer)
Dim dtUser As Date
Dim iAns As Integer
If Me.txtDate & "" <> "" Then ' Did the user enter anything?
dtUser = CDate(Me!txtDate)
' Is user entered date within seven days of today?
If dtUser > DateAdd("d", -7, Date()) AND _
dtUser < DateAdd("d", 7, Date()) Then
iAns = MsgBox("Dates within seven days of today require" _
& " a password.", vbOKCancel
If iAns = vbOK Then
DoCmd.OpenForm "frmPassword", WindowMode:=acDialog
' the form will have a command button caption OK which
' sets the form's Visible property to False
If Forms!frmPassword!txtPassword <> DLookUp("[Password]", _
"[tblUtility]") Then
MsgBox "Password incorrect"
Cancel = True
End If
Else
Cancel = True
End If
End If
End If
End Sub


John W. Vinson[MVP]
Join the online Access Chats
Tuesday 11am EDT - Thursday 3:30pm EDT
http://community.compuserve.com/msdevapps
 
Back
Top