Validating Fields

F

Fred Block

Hi,

I have a form with a bunch of fields on it. I must add some validation. I
thought this would be a simple task... well it seems I'm missing
"something".

NOTE: The "Type" on the value tab is "Date/Time". If I do not specify to
validate, it occurs but with a generic message (not specific to the textbox
the user is in). If I turn the Validation on for this field, it accepts a
valid value, then states that the value isn't valid!?!?

Some must be date fields and some numeric. Is there a way to validate
textbox entries without having to create them as a specific "Type"? Or...
once they're a specific Type, I need to undestand better how to set the
validation settings?

Thanks in advance! -- Fred
 
S

Sue Mosher [MVP-Outlook]

For best results, don't use the "this field requires a value" simple
validation. Instead,use a validation formula. Using a validation formula
will allow you to present the user with a validation message specific to
that field.

You can only validate text box entries with a formula if the text box is
bound to an Outlook property. For unbound text boxes, you can perform
validation in the Item_Send or Item_Write event handler.
 
F

Fred Block

Hi Sue,
You can only validate text box entries with a formula if the text box is
bound to an Outlook property. For unbound text boxes, you can perform
validation in the Item_Send or Item_Write event handler.

What do you mean when you say bound to an Outlook property? How is binding
accomplished. Perhaps I need to know this as well to determine what I must
do next.

Also...Is the Item_Send or Item_Write event handler supported in VBScript?

Thanks again! -- Fred
 
S

Sue Mosher [MVP-Outlook]

Look on the Properties dialog of a control, on the Value tab. If a field is
listed at the top, any data entered in the control will be stored in that
field in the Outlook item. If no field is listed at the top, it's an unbound
control and any data in the control will be discard when the item closes,
unless you use code to save it in some Outlook property.

You can see the Item-level events if you choose Script | Event Handler in
the Outlook form code window.

--
Sue Mosher, Outlook MVP
Author of
Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
 
F

Fred Block

Hi Again Sue,
...If no field is listed at the top, it's an unbound
control and any data in the control will be discard when the item closes,
unless you use code to save it in some Outlook property.

All my controls are bound as it turns out. That said, if I'm trying to
validate a field value as a date, shouldn't I be able to use the following
for the Validation Formula?: IsDate([21. Start Date]) ... Where "21. Start
Date" is the field name.

Also - for this to work, does the Value tab's "Type" setting have to be
"Date/Time" or should "Text" work?

You can see the Item-level events if you choose Script | Event Handler in
the Outlook form code window.

I hope to set these in Properties if possible. I'll code if necessary
though.

Thanks again! -- Fred
 
S

Sue Mosher [MVP-Outlook]

Yes, that's the way validation formulas work in general -- they return True
for good data and False for bad data.

You do not, however, need to use IsDate() to validate a date/time field.
Outlook automatically warns the user if they enter anything other than a
valid date/time in such a field.

If, however, you want users to enter dates in a text field, rather than a
date/time field, then it would be appropriate to use IsDate() in your
validation formula.

--
Sue Mosher, Outlook MVP
Author of
Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers



Fred Block said:
Hi Again Sue,
...If no field is listed at the top, it's an unbound
control and any data in the control will be discard when the item closes,
unless you use code to save it in some Outlook property.

All my controls are bound as it turns out. That said, if I'm trying to
validate a field value as a date, shouldn't I be able to use the following
for the Validation Formula?: IsDate([21. Start Date]) ... Where "21.
Start
Date" is the field name.

Also - for this to work, does the Value tab's "Type" setting have to be
"Date/Time" or should "Text" work?
 
F

Fred Block

Hi Sue,
You do not, however, need to use IsDate() to validate a date/time field.
Outlook automatically warns the user if they enter anything other than a
valid date/time in such a field.

I've added code and can get a MsgBox up that notifies the user of an
incorrect entry (TextBox and IsDate in VBScript). However, if the input by
user is incorrcect, how can I force the MailItem form to stay opened and not
close so the user can correct their entry?

Thanks again for all the help!


- Fred
 
S

Sue Mosher [MVP-Outlook]

You didn't say where you added the code. If it's in the Item_Send event
handler, set Item_Send = False to cancel that event.

--
Sue Mosher, Outlook MVP
Author of
Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers
 
F

Fred Block

Hi Sue,
You didn't say where you added the code. If it's in the Item_Send event
handler, set Item_Send = False to cancel that event.

The code was in the Item_Send function. I placed the code there in it stays
opened as desired. Thanks a mint!

-- Fred
 

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