Home |
Search |
Today's Posts |
#1
|
|||
|
|||
Form - required field(s) valid date
Hello,
I've created a form and need to make the first field (Text15) require that the user enter a valid date, without bypassing it or leaving it blank. I have modified the properties of the text box so that it's type is Date and set it's Date Format, however in testing I have found that if the user does not enter anything in the field, there is no way to require a valid date be entered, that is only if I enter text or something else invalid. Thank you, Michael |
#2
|
|||
|
|||
See http://word.mvps.org/FAQs/TblsFldsFm...ateFFields.htm
-- Suzanne S. Barnhill Microsoft MVP (Word) Words into Type Fairhope, Alabama USA Word MVP FAQ site: http://word.mvps.org Email cannot be acknowledged; please post all follow-ups to the newsgroup so all may benefit. "Michael M via OfficeKB.com" wrote in message ... Hello, I've created a form and need to make the first field (Text15) require that the user enter a valid date, without bypassing it or leaving it blank. I have modified the properties of the text box so that it's type is Date and set it's Date Format, however in testing I have found that if the user does not enter anything in the field, there is no way to require a valid date be entered, that is only if I enter text or something else invalid. Thank you, Michael |
#3
|
|||
|
|||
Michael M via OfficeKB.com wrote:
Hello, I've created a form and need to make the first field (Text15) require that the user enter a valid date, without bypassing it or leaving it blank. I have modified the properties of the text box so that it's type is Date and set it's Date Format, however in testing I have found that if the user does not enter anything in the field, there is no way to require a valid date be entered, that is only if I enter text or something else invalid. Thank you, Michael See http://word.mvps.org/FAQs/TblsFldsFm...ateFFields.htm. -- Regards, Jay Freedman Microsoft Word MVP FAQ: http://word.mvps.org |
#4
|
|||
|
|||
Suzanne,
Thank you for the link, I did actually find that earlier and have attempted to use that macro, but it does not work for me? I see no change when I enter the form or the field, I am using Word XP. How should I be entering this as a new macro, from the Tools Macros Macros Create and I pasted this; Sub ExitText2() With ActiveDocument.FormFields("Text2") If Len(.Result) 0 And Left$(.Result, 3) "KLM" Then Application.OnTime When:=Now + TimeValue("00:00:01"), Name: ="GoBacktoText2" MsgBox "The first three letters must be 'KLM'" End If End With End Sub Sub GoBacktoText2() ActiveDocument.Bookmarks("Text2").Range.Fields(1). Result.Select End Sub Modifying it for my field "Text15" but it does not do anything? I notice no change at all ... should this be selected as the "entry" or "exit" macro? Thank you, Michael Suzanne S. Barnhill wrote: See http://word.mvps.org/FAQs/TblsFldsFm...ateFFields.htm Hello, [quoted text clipped - 8 lines] Thank you, Michael -- Message posted via OfficeKB.com http://www.officekb.com/Uwe/Forums.a...neral/200508/1 |
#5
|
|||
|
|||
Hi Michael,
Item 1: Select this macro as the exit macro for your field. Item 2: Make sure you change "Text2" to "Text15" in all five places where it occurs. Item 3: You need to change the "If" statement (the third line of the ExitText2 macro). The macro as you copied it from the web page is only an example of the kind of thing you can do, and this particular example is checking to be sure the field contents start with the letters KLM -- not what you want. To check that the field is not empty, that line should be replaced by If Len(.Result) = 0 Then You'll also want to change the message in the MsgBox statement to something like "The date field cannot be blank". -- Regards, Jay Freedman Microsoft Word MVP FAQ: http://word.mvps.org Michael M via OfficeKB.com wrote: Suzanne, Thank you for the link, I did actually find that earlier and have attempted to use that macro, but it does not work for me? I see no change when I enter the form or the field, I am using Word XP. How should I be entering this as a new macro, from the Tools Macros Macros Create and I pasted this; Sub ExitText2() With ActiveDocument.FormFields("Text2") If Len(.Result) 0 And Left$(.Result, 3) "KLM" Then Application.OnTime When:=Now + TimeValue("00:00:01"), Name: ="GoBacktoText2" MsgBox "The first three letters must be 'KLM'" End If End With End Sub Sub GoBacktoText2() ActiveDocument.Bookmarks("Text2").Range.Fields(1). Result.Select End Sub Modifying it for my field "Text15" but it does not do anything? I notice no change at all ... should this be selected as the "entry" or "exit" macro? Thank you, Michael Suzanne S. Barnhill wrote: See http://word.mvps.org/FAQs/TblsFldsFm...ateFFields.htm Hello, [quoted text clipped - 8 lines] Thank you, Michael |
#6
|
|||
|
|||
Thank you! That works beautifully, and I have made slight additions/changes
to it. Thanks again! Jay Freedman wrote: Hi Michael, Item 1: Select this macro as the exit macro for your field. Item 2: Make sure you change "Text2" to "Text15" in all five places where it occurs. Item 3: You need to change the "If" statement (the third line of the ExitText2 macro). The macro as you copied it from the web page is only an example of the kind of thing you can do, and this particular example is checking to be sure the field contents start with the letters KLM -- not what you want. To check that the field is not empty, that line should be replaced by If Len(.Result) = 0 Then You'll also want to change the message in the MsgBox statement to something like "The date field cannot be blank". Suzanne, [quoted text clipped - 33 lines] Thank you, Michael -- Message posted via OfficeKB.com http://www.officekb.com/Uwe/Forums.a...neral/200508/1 |
Reply |
Thread Tools | |
Display Modes | |
|
|
Similar Threads | ||||
Thread | Forum | |||
Blank return for drop-down form fields | Microsoft Word Help | |||
Pop-up on 'save' about required form fields | Tables | |||
How to keep date issued (not created) on protected form? | Microsoft Word Help | |||
How do I use a form then mailmerge without losing the form fields | Mailmerge | |||
Having multiple form fields automatically updated | Microsoft Word Help |