WeekDay has to land on Friday

pablavo

Registered User.
Local time
Today, 15:34
Joined
Jun 28, 2007
Messages
189
Hi There.

I would think that I could work this out but I can't

All I'm trying to do is make sure that, if a user enters a date into a field and it's not on a friday, then a dialog will pop up telling the user it has to be a friday.

it's a short date, I'm not sure if i'd use weekday function or something.

Can anyone advise. Thank you
 
Code:
if format(me!date_field,"dddd") <> "Friday" Then
   msgbox("Date must be a friday")
end if

You could also use the weekday function

Code:
if weekday(me!date_field) <> vbfriday then
   msgbox("Date must be a friday")
end if
 
or you could

a) let the user pick a date
b) if the date isnt a friday, then go forwards or backwards TO a friday

while weekday(indate).ne.vbfriday
indate=indate-1 'goes backwards
wend
 
In addition to chergh's reply (and I would go with the second of those) then the code needs to be put in the Before_Update event of the control, if you don't want to allow the user to move to another field until the correct date is in.

Or perhaps you could just add a function that adds (or subtracts) however many dates to the date entered so that it makes it a Friday.
 
thanks for the help folks. I did chose the second of the two. I knew there was a way to do it with weekday but didn't know the syntax.

Thanks.
 

Users who are viewing this thread

Back
Top Bottom