Validate or default date to the first of the month...

L

Lynndyhop

Hi There

I have a date field where I know that the day is always required to be the first of the month. Is there a way to default just the day or to validate that the day is always the 1st

Much thanks

Lynndyhop
 
G

Gerald Stanley

Try something like

If Day([dateControl]) > 1 Then
[dateControl] = DateAdd("d" , 1 - Day([dateControl]),
[dateControl])
End If

Hope This Helps
Gerald Stanley MCSD
-----Original Message-----
Hi There!

I have a date field where I know that the day is always
required to be the first of the month. Is there a way to
default just the day or to validate that the day is always
the 1st?
 
A

Allen Browne

Open the table in design view.

Set the Default Value of the field to:
=DateSerial(Year(Date()),Month(Date()),1)

Set the field's Validation Rule to:
Is Null Or Day([MyDate])=1
where "MyDate" represents the name of your field.

--
Allen Browne - Microsoft MVP. Perth, Western Australia.

Reply to group, rather than allenbrowne at mvps dot org.

Lynndyhop said:
I have a date field where I know that the day is always required to be the
first of the month. Is there a way to default just the day or to validate
that the day is always the 1st?
 

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

Top