Nested If Then and Or Validation for Required Field

J

JBark

I have 3 fields named PUREP1, PUCHG1 and ASIPU.

ASIPU needs to be required if either PURREP1 or PUCHG1 have "If
Len(.Result)=0" character indicated in the field.

I am currently using this could for my required field validation but my
other fields are not conditional based on another fields character count. Can
I adapt this to work or do I need a different solution?

Sub PRODUCTrequired()
'
' PRODUCTrequired Macro
' Macro created 6/11/09 by Art Dep
'
With ActiveDocument.FormFields("PRODUCTrequired")
If Len(.Result) = 0 Then
Application.OnTime When:=Now + TimeValue("00:00:01"),
Name:="GoBacktoPRODUCTrequired"
MsgBox "This field is required."
End If
End With
End Sub

Sub GoBacktoPRODUCTrequired()
ActiveDocument.Bookmarks("PRODUCTrequired").Range.Fields(1).Result.Select
End Sub
 
J

JBark

Graham,

I've looked at the code on the web page you supplied but I don't understand
how the code knows it should be comparing field ASIPU with fields PURE1 or
PUCHG1? And not some other field in my doc? These are fields in a doc layout
not fields created using the "form tools".
 
G

Graham Mayor

Your original message showed code referring to the validation of formfields,
so it was reasonable to assume that you wanted to validate form fields,
which is what the link to the code I posted does. The exit macro is run on
exit from the field you wish to validate and the entry macro is run on entry
to the other fields. You are unable to leave a formfield with the exit macro
that is incomplete.

However as you now say that these are not form fields, you need to supply
more information about what sort of fields they are in what Word version and
how they are being used.

--
<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
Graham Mayor - Word MVP


<>>< ><<> ><<> <>>< ><<> <>>< <>><<>
 

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