View Single Post
 
Old 07-20-2017, 10:47 PM
Cath2017 Cath2017 is offline Windows 7 32bit Office 2010 32bit
Novice
 
Join Date: Jul 2017
Posts: 3
Cath2017 is on a distinguished road
Default Code for multiple conditions to be met to display a pop up message

Hi, I am working on a Word form template which will be progressively completed by multiple people. One person will start completing the form, then another will check and complete the next section, then finally a third will check and sign-off.
I would like the final user to not be able to save the document until one particular field is completed.
I have found the following code which will not allow the form to be saved if that field is missing.
Sub FileSave()

Dim orng As Word.Range
Dim ofld As FormFields
Set orng = ActiveDocument.Range
Set ofld = orng.FormFields
For i = 1 To ofld.Count
ofld(i).Select
' ****
If ofld(i).Name = "PrimaryGroup" Then
If ofld(i).Result = "Select..." Then
MsgBox ofld(i).Name & " must be completed"
Exit Sub
End If
End If
'****
Next i
ActiveDocument.Save
End Sub


The lines between the two '**** create the pop-up box, but I want this code to only run if a previous field "TriagedBy" has been completed.

So, I have been thinking I need another If statement prior to the one above which says something along the lines of If TriagedBy is <> "" then to run the code above, otherwise, if TriagedBy = "" then continue to save the document.
I am just not sure how it all fits together.

Any help is much appreciated!
Reply With Quote