Not DatePart

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

Guest

Hello,
I want to limit the date User's can input into a field to be a Friday.

I have the following code in the BeforeUpdate Event of the Date Field

If (Not (DatePart ("d", [DateField]))=6) Then
MsgBox ("Please Enter Friday's Date")
End If

I have changed the parenthesis around (among other trials and errors) but my
results are always the same. No matter which date I put into the DateField,
I get the Message "Please Enter Friday's Date".

Can you assist me with what I am doing wrong?
Thank you
Captain OhNo
 
the d gives you the day of month. Use w for day of week.

If Not (DatePart("w", [Text0]) = 6) Then
MsgBox ("Please Enter Friday's Date")
End If
 
It worked. So, now you know how I got my nickname...
Captain OhNo
Thank you

AccessExpert said:
the d gives you the day of month. Use w for day of week.

If Not (DatePart("w", [Text0]) = 6) Then
MsgBox ("Please Enter Friday's Date")
End If


Captain OhNo said:
Hello,
I want to limit the date User's can input into a field to be a Friday.

I have the following code in the BeforeUpdate Event of the Date Field

If (Not (DatePart ("d", [DateField]))=6) Then
MsgBox ("Please Enter Friday's Date")
End If

I have changed the parenthesis around (among other trials and errors) but my
results are always the same. No matter which date I put into the DateField,
I get the Message "Please Enter Friday's Date".

Can you assist me with what I am doing wrong?
Thank you
Captain OhNo
 
"d" returns day of the month. You actually want "w" which returns weekday.

Check Access VB Help for the argument "firstdayofweek" also.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Back
Top