![]() |
#1
|
|||
|
|||
![]()
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! |
#2
|
||||
|
||||
![]()
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 |
#3
|
|||
|
|||
![]()
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. |
#4
|
||||
|
||||
![]()
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 |
#5
|
|||
|
|||
![]()
Thanks for your help. I emailed you the file this morning.
|
![]() |
|
![]() |
||||
Thread | Thread Starter | Forum | Replies | Last Post |
Alternative for Multiple If Conditions? | zguan1 | Excel | 2 | 05-25-2017 09:12 AM |
![]() |
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 |
![]() |
z941714 | Excel | 8 | 08-09-2015 04:12 PM |
![]() |
bundy5150 | Excel | 4 | 02-22-2011 10:00 AM |