Form issue

A

ah

Hi, I would appreciate if someone could help me with the following form
problem:

I've created a form with Microsoft word. Besides, I've formatted 1 of the
field as "Date". However, I faced an issue as follows:

The date format that I've set is DD.MM.YYYY
When the user key in an invalid date, for example: 22.22.2006
The document will automatically reflect it back to current date.

Is it possible for the document to prompt out a msg "Invalid date" in stead
of change it to my current date in this case?

Please advice.

Thanks in advance.
 
J

Jean-Guy Marcil

ah was telling us:
ah nous racontait que :
Hi, I would appreciate if someone could help me with the following
form problem:

I've created a form with Microsoft word. Besides, I've formatted 1 of
the field as "Date". However, I faced an issue as follows:

The date format that I've set is DD.MM.YYYY
When the user key in an invalid date, for example: 22.22.2006
The document will automatically reflect it back to current date.

Is it possible for the document to prompt out a msg "Invalid date" in
stead of change it to my current date in this case?

Use this macro for the OnExit macro of the date field:
This is assuming that today's date can never be a valid/logical choice for
this date field.

Sub ValidateDate()

With Selection.Bookmarks(1).Range.Fields(1)
If .Result = Format(Date, "DD.MM.YYYY") Then
MsgBox "The date you entered is invalid, today's date " _
& "has been set instead.", vbExclamation, "Invalid Date"
End If
End With
End Sub



--
Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
(e-mail address removed)
Word MVP site: http://www.word.mvps.org
 
A

ah

Jean-Guy Marcil said:
ah was telling us:
ah nous racontait que :


Use this macro for the OnExit macro of the date field:
This is assuming that today's date can never be a valid/logical choice for
this date field.

Sub ValidateDate()

With Selection.Bookmarks(1).Range.Fields(1)
If .Result = Format(Date, "DD.MM.YYYY") Then
MsgBox "The date you entered is invalid, today's date " _
& "has been set instead.", vbExclamation, "Invalid Date"
End If
End With
End Sub



--
Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
(e-mail address removed)
Word MVP site: http://www.word.mvps.org

Thanks for your reply. Just wish to find out from you whether there is any
alternative solution to this? For your information, I don't have any macro in
place now. I still managed to get message "A valid date or time is required"
when I enter an invalid date. However, when I enter an invalid month, for
example: 12.13.2006
The system will change the month to date. As a result , the system will
change it to 13.12.2006 automatically.

And the other scenario is that if both the date and month are invalid, the
system will change it to today's date automatically. Please advice whether
there is any other alternative to resolve this besides macro.
 
J

Jean-Guy Marcil

ah was telling us:
ah nous racontait que :
Thanks for your reply. Just wish to find out from you whether there
is any alternative solution to this? For your information, I don't
have any macro in place now. I still managed to get message "A valid
date or time is required" when I enter an invalid date. However, when
I enter an invalid month, for example: 12.13.2006
The system will change the month to date. As a result , the system
will change it to 13.12.2006 automatically.

And the other scenario is that if both the date and month are
invalid, the system will change it to today's date automatically.
Please advice whether there is any other alternative to resolve this
besides macro.

To check for invalid month/date so that a message is popped up to the user
you will need a macro.
The message you see is issued by Word when the format is wrong.

--
Salut!
_______________________________________
Jean-Guy Marcil - Word MVP
(e-mail address removed)
Word MVP site: http://www.word.mvps.org
 

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