vbSunday

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

Guest

I would like to have each new record start with the first day of the week
(vbSunday) e.g. first record date would be 03-Sep-06 next record date
10-Sep-06 etc. Each time I start a new record I would like the Date to appear
in the Date field. This is for scheduling purposes. Each record equals a
scheduled event on the coming week. Each new date would have to be vbSunday
and continually add seven days fron previous date.
 
Sandrao,

If you won't have any missing weeks, you can make the DefaultValue for the
field equal to the max date in the table + 7:

Enter into the DefaultValue property:
=DMax("[YourDateField]","YourTable")+7

You could also set the textbox' Locked property to Yes to avoid changes. If
you wish to permit the user to enter ANY Sunday, you can use the BeforeUpdate
event of the form:

' BeforeUpdate code
If Weekday(Me![YourDateTextBox]) <> vbSunday Then
MsgBox "Date must be a Sunday."
Cancel = True
' Optionally set the textbox to the max date + 7 as above here
Me![YourDateTextBox].SetFocus
End If

Hope that helps.
Sprinks
 
Back
Top