How do I only accept a MONDAY date on a Form?

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

Guest

I have a form to input dates but some must only ever be a MONDAY so I need a validation rule, I have found something that may work but I am also having trouble placing the rule onto ACCESS.
 
Dear Gary,

Why not create a date selector combobox which takes its
dates from a table that only has a list of Mondays and set
the Limit To List property to True so the user can only
select one of the dates.

Alastair
-----Original Message-----
I have a form to input dates but some must only ever be a
MONDAY so I need a validation rule, I have found something
that may work but I am also having trouble placing the
rule onto ACCESS.
 
I have a form to input dates but some must only ever be a MONDAY so I need a validation rule, I have found something that may work but I am also having trouble placing the rule onto ACCESS.

You can use the weekday() function:

If WeekDay([DateField]) = 2 Then
' It's Monday
Else
' It's Not
End If

See the arguments for the Weekday function (in VBA Help) if Sunday is
not your first day of the week,
 
if Weekday([datefield])=2 then ....

Jim
-----Original Message-----
I have a form to input dates but some must only ever be a
MONDAY so I need a validation rule, I have found something
that may work but I am also having trouble placing the rule
onto ACCESS.
 
I have a form to input dates but some must only ever be a MONDAY so I need a validation rule, I have found something that may work but I am also having trouble placing the rule onto ACCESS.

Be nice to your users: let them enter any date they want and reset it
to the previous Monday in the control's AfterUpdate() event.

Private Sub txtDatefield_AfterUpdate()
Me!txtDateField = DateAdd("d", _
1 - DatePart("w", Me!txtDateField, vbMonday), Me!txtDateField)
End Sub
 
Back
Top