Coding Help

G

Guest

How do I utilize a "Cancel Action on Save" script, to cancel the action of
saving a contact form if a certain field is null. I have a Custom Form, that
labels certain fields as required based on the value of another field. I
would like these fields "labelled" as required to actually be required. So,
I was thinking that if one of these "required" fields is null when the user
tries to save the contact form, an error message can pop up saying which
required field needs to be populated. I was told to try a "Cancel Action"
action OnSave if...something. Can anyone help?
 
S

Sue Mosher [MVP-Outlook]

Function Item_Write()
If Item.UserProperties("Your prop") = "" Then
Item_Write = False
MsgBox "Fill in the YOUR PROP field."
End If
End Function
 
G

Guest

Thanks for the quick response Sue. If you remember me from OutlookCode.com,
I'm not very good with Code. That looks like it'll work. Let me give you
the specific details and maybe you can help me a bit further. I have a field
(ReqResearch) that populates with a value of "Required" when a certain Check
Box is checked. When that is true, I want another field, (DataResearch) to
be required. In other words, If (ReqResearch) = "Required", then
(DataResearch) cannot be "". Can you help me fix that, please? Thank you so
very much.
 
S

Sue Mosher [MVP-Outlook]

You don't need code for that. You can do it with a validation formula on the
control that displays DataResearch:

([ReqResearch] <> "Required") OR ([DataResearch] <> "")

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

Guest

Oh. I should've thought of that. Thank you. I input the following formula
into the Validation box: IIf([ReqResearch]="Required",<>"") -- So now I'm
getting an error saying the value I entered into the field is not valid.
Even if [ReqResearch] <>"Required" I still get the same message. Did I do
something wrong?

Sue Mosher said:
You don't need code for that. You can do it with a validation formula on the
control that displays DataResearch:

([ReqResearch] <> "Required") OR ([DataResearch] <> "")

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



Micah Chaney said:
Thanks for the quick response Sue. If you remember me from
OutlookCode.com,
I'm not very good with Code. That looks like it'll work. Let me give you
the specific details and maybe you can help me a bit further. I have a
field
(ReqResearch) that populates with a value of "Required" when a certain
Check
Box is checked. When that is true, I want another field, (DataResearch)
to
be required. In other words, If (ReqResearch) = "Required", then
(DataResearch) cannot be "". Can you help me fix that, please? Thank you
so
very much.
 
S

Sue Mosher [MVP-Outlook]

Why didn't you try the formula I suggested? Yours won't work. A validation
formula must return True if the data is "good" and False if it isn't.

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



Micah Chaney said:
Oh. I should've thought of that. Thank you. I input the following
formula
into the Validation box: IIf([ReqResearch]="Required",<>"") -- So now I'm
getting an error saying the value I entered into the field is not valid.
Even if [ReqResearch] <>"Required" I still get the same message. Did I do
something wrong?

Sue Mosher said:
You don't need code for that. You can do it with a validation formula on
the
control that displays DataResearch:

([ReqResearch] <> "Required") OR ([DataResearch] <> "")

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



Micah Chaney said:
Thanks for the quick response Sue. If you remember me from
OutlookCode.com,
I'm not very good with Code. That looks like it'll work. Let me give
you
the specific details and maybe you can help me a bit further. I have a
field
(ReqResearch) that populates with a value of "Required" when a certain
Check
Box is checked. When that is true, I want another field,
(DataResearch)
to
be required. In other words, If (ReqResearch) = "Required", then
(DataResearch) cannot be "". Can you help me fix that, please? Thank
you
so
very much.

:

Function Item_Write()
If Item.UserProperties("Your prop") = "" Then
Item_Write = False
MsgBox "Fill in the YOUR PROP field."
End If
End Function
message
How do I utilize a "Cancel Action on Save" script, to cancel the
action
of
saving a contact form if a certain field is null. I have a Custom
Form,
that
labels certain fields as required based on the value of another
field.
I
would like these fields "labelled" as required to actually be
required.
So,
I was thinking that if one of these "required" fields is null when
the
user
tries to save the contact form, an error message can pop up saying
which
required field needs to be populated. I was told to try a "Cancel
Action"
action OnSave if...something. Can anyone help?
 
G

Guest

I'm so sorry for being a pain...but I don't understand. Originally, I went
to ViewCode in the File Menu, and input your Function_Item code. It wasn't
working, which is why I gave you the field names that I was working with.
Then you mentioned I didn't need code, all I need was to enter a formula in
the Validation box of (DataResearch). I input exactly what you put down
([ReqResearch] <> "Required") and got an "Unknown Field" error. So I thought
you meant to actually input a formula with the expression ([ReqResearch] <>
"Required"). So, that's where that IIf statement below came from. I'm sorry
to take up so much of your time with my seeming ignorance...but I really am
not very good with code, and just need a little extra help. I have
everything else this form needs to have happen happening. Just this one
validation/required field thing that's got me stumped. If you could please
spare another moment, and try helping again, I'd really appreciate it.
Thanks.

Sue Mosher said:
Why didn't you try the formula I suggested? Yours won't work. A validation
formula must return True if the data is "good" and False if it isn't.

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



Micah Chaney said:
Oh. I should've thought of that. Thank you. I input the following
formula
into the Validation box: IIf([ReqResearch]="Required",<>"") -- So now I'm
getting an error saying the value I entered into the field is not valid.
Even if [ReqResearch] <>"Required" I still get the same message. Did I do
something wrong?

Sue Mosher said:
You don't need code for that. You can do it with a validation formula on
the
control that displays DataResearch:

([ReqResearch] <> "Required") OR ([DataResearch] <> "")

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



Thanks for the quick response Sue. If you remember me from
OutlookCode.com,
I'm not very good with Code. That looks like it'll work. Let me give
you
the specific details and maybe you can help me a bit further. I have a
field
(ReqResearch) that populates with a value of "Required" when a certain
Check
Box is checked. When that is true, I want another field,
(DataResearch)
to
be required. In other words, If (ReqResearch) = "Required", then
(DataResearch) cannot be "". Can you help me fix that, please? Thank
you
so
very much.

:

Function Item_Write()
If Item.UserProperties("Your prop") = "" Then
Item_Write = False
MsgBox "Fill in the YOUR PROP field."
End If
End Function



message
How do I utilize a "Cancel Action on Save" script, to cancel the
action
of
saving a contact form if a certain field is null. I have a Custom
Form,
that
labels certain fields as required based on the value of another
field.
I
would like these fields "labelled" as required to actually be
required.
So,
I was thinking that if one of these "required" fields is null when
the
user
tries to save the contact form, an error message can pop up saying
which
required field needs to be populated. I was told to try a "Cancel
Action"
action OnSave if...something. Can anyone help?
 
S

Sue Mosher [MVP-Outlook]

I copied ReqResearch from your original post. If that is not the actual name
of the field as you see it in the All Fields tab, correct the formula to use
the correct field name. The field name needs to be in brackets.
--
Sue Mosher, Outlook MVP
Author of
Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers



Micah Chaney said:
I'm so sorry for being a pain...but I don't understand. Originally, I
went
to ViewCode in the File Menu, and input your Function_Item code. It
wasn't
working, which is why I gave you the field names that I was working with.
Then you mentioned I didn't need code, all I need was to enter a formula
in
the Validation box of (DataResearch). I input exactly what you put down
([ReqResearch] <> "Required") and got an "Unknown Field" error. So I
thought
you meant to actually input a formula with the expression ([ReqResearch]
<>
"Required"). So, that's where that IIf statement below came from.
Sue Mosher said:
Why didn't you try the formula I suggested? Yours won't work. A
validation
formula must return True if the data is "good" and False if it isn't.

Micah Chaney said:
Oh. I should've thought of that. Thank you. I input the following
formula
into the Validation box: IIf([ReqResearch]="Required",<>"") -- So now
I'm
getting an error saying the value I entered into the field is not
valid.
Even if [ReqResearch] <>"Required" I still get the same message. Did I
do
something wrong?

:

You don't need code for that. You can do it with a validation formula
on
the
control that displays DataResearch:

([ReqResearch] <> "Required") OR ([DataResearch] <> "")

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



message
Thanks for the quick response Sue. If you remember me from
OutlookCode.com,
I'm not very good with Code. That looks like it'll work. Let me
give
you
the specific details and maybe you can help me a bit further. I
have a
field
(ReqResearch) that populates with a value of "Required" when a
certain
Check
Box is checked. When that is true, I want another field,
(DataResearch)
to
be required. In other words, If (ReqResearch) = "Required", then
(DataResearch) cannot be "". Can you help me fix that, please?
Thank
you
so
very much.

:

Function Item_Write()
If Item.UserProperties("Your prop") = "" Then
Item_Write = False
MsgBox "Fill in the YOUR PROP field."
End If
End Function



message
How do I utilize a "Cancel Action on Save" script, to cancel the
action
of
saving a contact form if a certain field is null. I have a
Custom
Form,
that
labels certain fields as required based on the value of another
field.
I
would like these fields "labelled" as required to actually be
required.
So,
I was thinking that if one of these "required" fields is null
when
the
user
tries to save the contact form, an error message can pop up
saying
which
required field needs to be populated. I was told to try a
"Cancel
Action"
action OnSave if...something. Can anyone help?
 
G

Guest

Sue, Thank you so much for your help. I apologize again for having to take
up so much of your time. I finally got it to work. I created a third field
which I have invisible, with the validation code in it. I created the field
as a Formula field and made it a True/False IIf statement. For the
validation I said it must =True. It works. Thanks so much for all your help
and for being patient. I think my project is complete, and exceeds
expectations. Thanks again...Micah Chaney

Sue Mosher said:
I copied ReqResearch from your original post. If that is not the actual name
of the field as you see it in the All Fields tab, correct the formula to use
the correct field name. The field name needs to be in brackets.
--
Sue Mosher, Outlook MVP
Author of
Microsoft Outlook Programming - Jumpstart for
Administrators, Power Users, and Developers



Micah Chaney said:
I'm so sorry for being a pain...but I don't understand. Originally, I
went
to ViewCode in the File Menu, and input your Function_Item code. It
wasn't
working, which is why I gave you the field names that I was working with.
Then you mentioned I didn't need code, all I need was to enter a formula
in
the Validation box of (DataResearch). I input exactly what you put down
([ReqResearch] <> "Required") and got an "Unknown Field" error. So I
thought
you meant to actually input a formula with the expression ([ReqResearch]
<>
"Required"). So, that's where that IIf statement below came from.
Sue Mosher said:
Why didn't you try the formula I suggested? Yours won't work. A
validation
formula must return True if the data is "good" and False if it isn't.

Oh. I should've thought of that. Thank you. I input the following
formula
into the Validation box: IIf([ReqResearch]="Required",<>"") -- So now
I'm
getting an error saying the value I entered into the field is not
valid.
Even if [ReqResearch] <>"Required" I still get the same message. Did I
do
something wrong?

:

You don't need code for that. You can do it with a validation formula
on
the
control that displays DataResearch:

([ReqResearch] <> "Required") OR ([DataResearch] <> "")

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



message
Thanks for the quick response Sue. If you remember me from
OutlookCode.com,
I'm not very good with Code. That looks like it'll work. Let me
give
you
the specific details and maybe you can help me a bit further. I
have a
field
(ReqResearch) that populates with a value of "Required" when a
certain
Check
Box is checked. When that is true, I want another field,
(DataResearch)
to
be required. In other words, If (ReqResearch) = "Required", then
(DataResearch) cannot be "". Can you help me fix that, please?
Thank
you
so
very much.

:

Function Item_Write()
If Item.UserProperties("Your prop") = "" Then
Item_Write = False
MsgBox "Fill in the YOUR PROP field."
End If
End Function



message
How do I utilize a "Cancel Action on Save" script, to cancel the
action
of
saving a contact form if a certain field is null. I have a
Custom
Form,
that
labels certain fields as required based on the value of another
field.
I
would like these fields "labelled" as required to actually be
required.
So,
I was thinking that if one of these "required" fields is null
when
the
user
tries to save the contact form, an error message can pop up
saying
which
required field needs to be populated. I was told to try a
"Cancel
Action"
action OnSave if...something. Can anyone help?
 
S

Sue Mosher [MVP-Outlook]

Nice. What do your IIf statement and validation formula look like? You don't
need to say <my formula> = True. That's redundant. Simply <my formula>
suffices, as long as it evaluates to only True or False.

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



Micah Chaney said:
Sue, Thank you so much for your help. I apologize again for having to
take
up so much of your time. I finally got it to work. I created a third
field
which I have invisible, with the validation code in it. I created the
field
as a Formula field and made it a True/False IIf statement. For the
validation I said it must =True. It works. Thanks so much for all your
help
and for being patient. I think my project is complete, and exceeds
expectations. Thanks again...Micah Chaney

Sue Mosher said:
I copied ReqResearch from your original post. If that is not the actual
name
of the field as you see it in the All Fields tab, correct the formula to
use
the correct field name. The field name needs to be in brackets.
Micah Chaney said:
I'm so sorry for being a pain...but I don't understand. Originally, I
went
to ViewCode in the File Menu, and input your Function_Item code. It
wasn't
working, which is why I gave you the field names that I was working
with.
Then you mentioned I didn't need code, all I need was to enter a
formula
in
the Validation box of (DataResearch). I input exactly what you put
down
([ReqResearch] <> "Required") and got an "Unknown Field" error. So I
thought
you meant to actually input a formula with the expression
([ReqResearch]
<>
"Required"). So, that's where that IIf statement below came from.
:

Why didn't you try the formula I suggested? Yours won't work. A
validation
formula must return True if the data is "good" and False if it isn't.
message
Oh. I should've thought of that. Thank you. I input the following
formula
into the Validation box: IIf([ReqResearch]="Required",<>"") -- So
now
I'm
getting an error saying the value I entered into the field is not
valid.
Even if [ReqResearch] <>"Required" I still get the same message.
Did I
do
something wrong?

:

You don't need code for that. You can do it with a validation
formula
on
the
control that displays DataResearch:

([ReqResearch] <> "Required") OR ([DataResearch] <> "")

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



message
Thanks for the quick response Sue. If you remember me from
OutlookCode.com,
I'm not very good with Code. That looks like it'll work. Let me
give
you
the specific details and maybe you can help me a bit further. I
have a
field
(ReqResearch) that populates with a value of "Required" when a
certain
Check
Box is checked. When that is true, I want another field,
(DataResearch)
to
be required. In other words, If (ReqResearch) = "Required", then
(DataResearch) cannot be "". Can you help me fix that, please?
Thank
you
so
very much.

:

Function Item_Write()
If Item.UserProperties("Your prop") = "" Then
Item_Write = False
MsgBox "Fill in the YOUR PROP field."
End If
End Function



message
How do I utilize a "Cancel Action on Save" script, to cancel
the
action
of
saving a contact form if a certain field is null. I have a
Custom
Form,
that
labels certain fields as required based on the value of
another
field.
I
would like these fields "labelled" as required to actually be
required.
So,
I was thinking that if one of these "required" fields is null
when
the
user
tries to save the contact form, an error message can pop up
saying
which
required field needs to be populated. I was told to try a
"Cancel
Action"
action OnSave if...something. Can anyone help?
 
G

Guest

The Formula is: IIf([ReqResearch]="Required" and
[DataResearch]="",False,True)...And the validation Code is: ="True".

Sue Mosher said:
Nice. What do your IIf statement and validation formula look like? You don't
need to say <my formula> = True. That's redundant. Simply <my formula>
suffices, as long as it evaluates to only True or False.

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



Micah Chaney said:
Sue, Thank you so much for your help. I apologize again for having to
take
up so much of your time. I finally got it to work. I created a third
field
which I have invisible, with the validation code in it. I created the
field
as a Formula field and made it a True/False IIf statement. For the
validation I said it must =True. It works. Thanks so much for all your
help
and for being patient. I think my project is complete, and exceeds
expectations. Thanks again...Micah Chaney

Sue Mosher said:
I copied ReqResearch from your original post. If that is not the actual
name
of the field as you see it in the All Fields tab, correct the formula to
use
the correct field name. The field name needs to be in brackets.
I'm so sorry for being a pain...but I don't understand. Originally, I
went
to ViewCode in the File Menu, and input your Function_Item code. It
wasn't
working, which is why I gave you the field names that I was working
with.
Then you mentioned I didn't need code, all I need was to enter a
formula
in
the Validation box of (DataResearch). I input exactly what you put
down
([ReqResearch] <> "Required") and got an "Unknown Field" error. So I
thought
you meant to actually input a formula with the expression
([ReqResearch]
<>
"Required"). So, that's where that IIf statement below came from.


:

Why didn't you try the formula I suggested? Yours won't work. A
validation
formula must return True if the data is "good" and False if it isn't.


message
Oh. I should've thought of that. Thank you. I input the following
formula
into the Validation box: IIf([ReqResearch]="Required",<>"") -- So
now
I'm
getting an error saying the value I entered into the field is not
valid.
Even if [ReqResearch] <>"Required" I still get the same message.
Did I
do
something wrong?

:

You don't need code for that. You can do it with a validation
formula
on
the
control that displays DataResearch:

([ReqResearch] <> "Required") OR ([DataResearch] <> "")

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



message
Thanks for the quick response Sue. If you remember me from
OutlookCode.com,
I'm not very good with Code. That looks like it'll work. Let me
give
you
the specific details and maybe you can help me a bit further. I
have a
field
(ReqResearch) that populates with a value of "Required" when a
certain
Check
Box is checked. When that is true, I want another field,
(DataResearch)
to
be required. In other words, If (ReqResearch) = "Required", then
(DataResearch) cannot be "". Can you help me fix that, please?
Thank
you
so
very much.

:

Function Item_Write()
If Item.UserProperties("Your prop") = "" Then
Item_Write = False
MsgBox "Fill in the YOUR PROP field."
End If
End Function



message
How do I utilize a "Cancel Action on Save" script, to cancel
the
action
of
saving a contact form if a certain field is null. I have a
Custom
Form,
that
labels certain fields as required based on the value of
another
field.
I
would like these fields "labelled" as required to actually be
required.
So,
I was thinking that if one of these "required" fields is null
when
the
user
tries to save the contact form, an error message can pop up
saying
which
required field needs to be populated. I was told to try a
"Cancel
Action"
action OnSave if...something. Can anyone help?
 

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