|
|
Thread Tools | Display Modes |
#1
|
|||
|
|||
Needing to learn dependent drop downs and how to still keep the document editable
Hi everyone!
So I'm new to learning how to do dependent drop downs in word and I've read a lot of different articles and threads on here, but I can't quite find the info I need. I have a medical form in Word that my company has to fill out every time there is an incident. This form includes patient info, doctor info, drug info, and then a short description of what happened. The patient and doctor sections can be just copy-paste and the drug section is where I need the help. I need a drop down for Drug name, strength, dosage, and route (orally, subcutaneous, etc). When I select one drug name, I need the strength, dosage, and route lists to auto-update to match that drug. I know I can use the legacy drop down lists but to make those work, I have to lock the form from editing which means that people can't free hand where needed so I think I need to use combo box or drop down list content controls. Is there anyone that can help me with this please? |
#2
|
||||
|
||||
My friend Greg Maxey has done much work on this. I'll post him a link to this thread in case he has missed it.
__________________
Graham Mayor - MS MVP (Word) (2002-2019) Visit my web site for more programming tips and ready made processes www.gmayor.com |
#3
|
|||
|
|||
There are several ways to do that ranging from simply using the CC on exit event to mapping and monitoring the mapping update events.
Link "Conditional Content" to a List Selection |
#4
|
||||
|
||||
See also:
Dependent Dropdown Content Controls Help with cascading dropdown list Hierarchical Dropdown Content Controls Creating a reducing drop down list Dependent Text Content Controls Multiple entries in dropdown lists
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#5
|
|||
|
|||
Macropod thank you so much! I was able to copy-paste your VBA code from Dependent dropdown CC and just by changing the labels, it worked perfectly!
2 quick questions: 1. In this form I'm updating, I still want the next 2 fields to update but these are much simpler. I want something to the effect of "IF 'Eliquis', THEN '1 by mouth twice a day'' IF 'Orencia', THEN....." How do I do that or add that into the code? 2. Where can I go online to learn more about VBA and how to develop it myself? |
#6
|
||||
|
||||
Quote:
There are many such resources, including code samples on forums such as this. The quality is variable; avoid anything that uses lots of 'Selection', 'ActiveWindow.ActivePane.View.SeekView' and 'ChangeFileOpenDirectory' code, as that usually evidences heavy reliance on the macro recorder.
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#7
|
|||
|
|||
Hey Macropod!
Thank you again for all your help! I have one final question for you though if you don't mind! Here is a copy-paste of the section I've been working on: Product Information: Drug: Sprycel Strength: Choose an item. Dose: { IF { REF Drug \* MERGEFORMAT } = "Eliquis""1 by mouth twice a day""{ IF {REF Drug \* MERGEFORMAT } = "Orencia""Inject once under the skin once a week"" { IF {REF Drug \* MERGEFORMAT } = "Sprycel""1 by mouth once a day"}""}"" } Route: {IF {REF Drug \* MERGEFORMAT } = "Eliquis""Orally""{ IF {REF Drug \* MERGEFORMAT } ="Orencia""Subcutaneous""{IF {REF Drug \* MERGEFORMAT } ="Sprycel""Orally"}""}"" } When I hit alt-F9 both the dose and route disappear and just say "REF". If I select a drug, nothing happens in these fields. Can you advise why? The drug and strength fields are content control that you helped me with previously. Thank you |
#8
|
||||
|
||||
Firstly, there is no need to use field coding for this - the VBA code in:
Dependent Text Content Controls Multiple entries in dropdown lists shows how to make those updates directly from the relevant content control. Second, your use of fields means you'd have to add additional code to the ContentControlOnExit macro to get them to update. Third, even if field coding were used, you don't need the \* MERGEFORMAT switches. Fourth, in a document accessible for editing, there's a very real risk of someone overtyping/deleting the field coding; a content control, by comparison, can be protected against both. Finally, as you why you're getting that particular error, that may be because you've typed some of the braces instead of creating them via Ctrl-F9 or via Insert|Cross-reference. There should also be a space between your "" sets.
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#9
|
|||
|
|||
Ok so I didn't initially use the dependent CC because I have no clue where to add that into the VBA. Making it work for "drug" and "strength" was easy because all I had to do was change the labels in your example.
But how do I make room for 2 more fields? I'm so lost on what to do :/ |
#10
|
||||
|
||||
This would be a lot easier to resolve if you attached your document to a post (delete anything sensitive). You can do that via the paperclip symbol on the 'Go Advanced' tab at the bottom of this screen.
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#11
|
|||
|
|||
So sorry for all the confusion. I have attached the document in question. The section I'm working on is titled product details
|
#12
|
||||
|
||||
Now that I've seen the document, it's even simpler than I thought. See attached.
Note: if you save the document as a Word macro-enabled template (i.e. a dotm file), then distribute that: 1. There'll be little risk of users messing things up by overwriting it; and 2. The resulting documents created from it can be saved as docx files.
__________________
Cheers, Paul Edstein [Fmr MS MVP - Word] |
#13
|
|||
|
|||
Thank you so much! You're a godsend!
|
Tags |
content control, dependent dropdown list, vba |
Thread Tools | |
Display Modes | |
|
Similar Threads | ||||
Thread | Thread Starter | Forum | Replies | Last Post |
Help with Colour Coding drop downs. | Instructionalhelp | Word VBA | 11 | 03-15-2018 10:35 PM |
Lock specific drop downs on a Word Document | icarrus | Word | 1 | 09-30-2015 02:07 PM |
Drop Downs | Suray1911 | Excel | 1 | 09-29-2015 10:31 PM |
field shading for drop downs | rbd50 | Mail Merge | 3 | 03-31-2015 09:52 PM |
Drop-Downs: Run Macro on Exit | Andrew H | Word VBA | 15 | 11-16-2012 08:34 AM |