Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 07-20-2017, 10:47 PM
Cath2017 Cath2017 is offline Code for multiple conditions to be met to display a pop up message Windows 7 32bit Code for multiple conditions to be met to display a pop up message Office 2010 32bit
Novice
Code for multiple conditions to be met to display a pop up message
 
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
  #2  
Old 07-20-2017, 11:20 PM
gmayor's Avatar
gmayor gmayor is offline Code for multiple conditions to be met to display a pop up message Windows 10 Code for multiple conditions to be met to display a pop up message Office 2016
Expert
 
Join Date: Aug 2014
Posts: 4,137
gmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud of
Default

Without seeing the form and the fields involved, this is not easy to resolve. It appears that you are using legacy form fields, but how is it determined which of the three people involved are completing the form?

If you are only checking one field then no-one would be able to save it without filling that field. Surely the first two must be able to save without that field being completed?

What type of fields are the relevant fields e.g. Text, Dropdown, CheckBox?

What is the relationship between the named field "TriagedBy" and the field "PrimaryGroup" and various users who complete the form?

You are going to have to explain this a little better or attach a copy of the form.
__________________
Graham Mayor - MS MVP (Word) (2002-2019)
Visit my web site for more programming tips and ready made processes www.gmayor.com
Reply With Quote
  #3  
Old 07-20-2017, 11:36 PM
Cath2017 Cath2017 is offline Code for multiple conditions to be met to display a pop up message Windows 7 32bit Code for multiple conditions to be met to display a pop up message Office 2010 32bit
Novice
Code for multiple conditions to be met to display a pop up message
 
Join Date: Jul 2017
Posts: 3
Cath2017 is on a distinguished road
Default

As you may guess from the form I work in a specialist doctor clinic. The form begins be filled out by clerical staff, and then referrals are triaged for priority and which clinic to book into by other staff. I have attached an image of the form.

I wasn't clear in the original post (my apologies) but yes, I don't want the prompt to appear for the early users - only the final user who initials the "TriagedBy" box (which is just a text field) must complete the "Primary Clinic Group" box, which is a drop-down box with a set of options.
Attached Images
File Type: png Form.png (23.7 KB, 18 views)
Reply With Quote
  #4  
Old 07-21-2017, 01:30 AM
gmayor's Avatar
gmayor gmayor is offline Code for multiple conditions to be met to display a pop up message Windows 10 Code for multiple conditions to be met to display a pop up message Office 2016
Expert
 
Join Date: Aug 2014
Posts: 4,137
gmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud ofgmayor has much to be proud of
Default

OK, that's a bit clearer, but the screen shot doesn't show the field names and thus which is the "PrimaryGroup" field that must be completed by the triage doctor.

Can you attach the form to the thread (Go Advanced) or e-mail the blank form to me at supportATgmayor.com (change AT to @) with your username in the subject and I will see what can be done with it.
__________________
Graham Mayor - MS MVP (Word) (2002-2019)
Visit my web site for more programming tips and ready made processes www.gmayor.com
Reply With Quote
  #5  
Old 07-24-2017, 04:33 PM
Cath2017 Cath2017 is offline Code for multiple conditions to be met to display a pop up message Windows 7 32bit Code for multiple conditions to be met to display a pop up message Office 2010 32bit
Novice
Code for multiple conditions to be met to display a pop up message
 
Join Date: Jul 2017
Posts: 3
Cath2017 is on a distinguished road
Default

Thanks for your help. I emailed you the file this morning.
Reply With Quote
Reply



Similar Threads
Thread Thread Starter Forum Replies Last Post
Alternative for Multiple If Conditions? zguan1 Excel 2 05-25-2017 09:12 AM
Code for multiple conditions to be met to display a pop up message Using multiple conditions with an IF statement?? to show a yes/no value BlindMouse Excel 1 01-27-2016 12:19 AM
Vba that shows an error message for certain conditions Ellebb Word VBA 7 09-21-2015 11:24 PM
Code for multiple conditions to be met to display a pop up message Multiple If Conditions z941714 Excel 8 08-09-2015 04:12 PM
Code for multiple conditions to be met to display a pop up message Count with multiple conditions bundy5150 Excel 4 02-22-2011 10:00 AM

Other Forums: Access Forums

All times are GMT -7. The time now is 07:12 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2025, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2025 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft