Macro Validation?

  • Thread starter Thread starter twalsh
  • Start date Start date
T

twalsh

I have a macro running with a condition to check a date field "AfterUpdate".
the point is to see if a date entered is invalid. In this case an invalid
date is anything before last sunday, or sometime in the future or "within
this week"

I have
[Forms]![frmNewClockIssue]![Date]>Date()
checking to see if the date is in the future

and

DateValue([Forms]![frmNewClockIssue]![Week])<>DateValue([Forms]![frmNewClockIssue]![Date])+(7-Weekday([Forms]![frmNewClockIssue]![Date]))

checking to see if the date is before the previous sunday.

it wont run, or at least wont display the appropriate msgbox if i try to
trigger it. any thoughts?
 
Twalsh,

Do you have a control on the form named 'Week'? What is that meant for?

I am having difficulty knowing what constitutes a valid date. If it
can't be in the future, and it can't be before Sunday, and it can't be
this week, what's left? Never?
 
yeah, sorry, i changed my mind throughout writing the question :\

I have a control in the form for week. The week needs to be a date and can
only be a Saturday. Actually while typing this i decided just to figure out
how to have that control be the next saturday by default....Duh....

The problem will be making sure that whatever the user puts in the "Date"
Control is a date within that week. (our company's "week" runs from
sunday-saturday). I also do not want the user to be able to put a future date
in the "Date" Control, even if it is within the same week.

Steve Schapel said:
Twalsh,

Do you have a control on the form named 'Week'? What is that meant for?

I am having difficulty knowing what constitutes a valid date. If it
can't be in the future, and it can't be before Sunday, and it can't be
this week, what's left? Never?

--
Steve Schapel, Microsoft Access MVP
I have a macro running with a condition to check a date field "AfterUpdate".
the point is to see if a date entered is invalid. In this case an invalid
date is anything before last sunday, or sometime in the future or "within
this week"

I have
[Forms]![frmNewClockIssue]![Date]>Date()
checking to see if the date is in the future

and

DateValue([Forms]![frmNewClockIssue]![Week])<>DateValue([Forms]![frmNewClockIssue]![Date])+(7-Weekday([Forms]![frmNewClockIssue]![Date]))

checking to see if the date is before the previous sunday.

it wont run, or at least wont display the appropriate msgbox if i try to
trigger it. any thoughts?
 
TWalsh,

Ok, thanks for the further information.

By the way, I should point out that 'date' and 'week' are Reserved Words
(i.e. have a special meaning) in Access, and as such should ot be used
as the names of fields or controls. I suggest you change them if you can.

So, if the 'Week' control will be set to default to the coming Saturday,
then I expect the easiest way to wriite the Condition for the After
Update macro of the Date control would be:
[Date] Between [Week]-6 And Date()
 
Back
Top