Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 01-11-2020, 11:52 AM
NLJ NLJ is offline Dependent dropdown and repeat section Windows 10 Dependent dropdown and repeat section Office 2016
Novice
Dependent dropdown and repeat section
 
Join Date: Jan 2020
Posts: 5
NLJ is on a distinguished road
Default Dependent dropdown and repeat section

I have no experience with VBA and really limited experience using content controls. I'm helping to create a report template to use for approximately a year until we get into an electronic system. The goal is to create efficiency and make reports quicker and easier to complete. There are several content controls and one section to allow free text and lists and a dependent relationship between category and sub-category. The entire section should be repeatable as each report will have a varying number of observations to include. I have been able to modify a VBA code from another website which works for one observation, but this won't work for any additional observations whether I copy and paste or use the section repeat content control. I'm not sure if this makes sense, but I'm hoping that someone can help.


Code:
Sub PopulateddCategory()
    Dim xDirection As FormField
    Dim xState As FormField
    On Error Resume Next
    Set xDirection = ActiveDocument.FormFields("ddCategory")
    Set xState = ActiveDocument.FormFields("ddSub")
    If ((xDirection Is Nothing) Or (xState Is Nothing)) Then Exit Sub
    With xState.DropDown.ListEntries
        .Clear
        Select Case xDirection.Result
            Case "Business Continuity Disaster Recovery"
                .Add "Adherence"
                .Add "Documentation"
                .Add "Procedure"
            Case "Computerized Systems Management"
                .Add "Adherence"
                .Add "Documentation"
                .Add "Procedure"
                .Add "Validation"
            Case "Contract  Agreement"
                .Add "Adherence"
                .Add "Documentation"
                .Add "Procedure"
            Case "Data Collection and Handling"
                .Add "Adherence"
                .Add "Documentation"
                .Add "Procedure"
                .Add "Source Data Verification"
            Case "Good Documentation Practices"
                .Add "Adherence"
                .Add "Procedure"
            Case "Records Management"
                .Add "Investigator Site File"
                .Add "Procedure"
                .Add "Trial Master File Master File"
            End Select
    End With
End Sub
Attached Files
File Type: docm Repeating Dependant DD Question.docm (61.4 KB, 11 views)

Last edited by macropod; 01-11-2020 at 01:31 PM. Reason: Added code tags
Reply With Quote
  #2  
Old 01-11-2020, 01:46 PM
macropod's Avatar
macropod macropod is offline Dependent dropdown and repeat section Windows 7 64bit Dependent dropdown and repeat section Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,956
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Your code indicates you're using formfields, not content controls for the dropdowns. The two are entirely different. Moreover, you seem to have all the existing content inside a single rich-text content control. Bad idea. Content controls and formfields were not designed to be used together and trying to do so can lead to problems.

Your basic issue can be solved by using a Word table as a container, and a suitable macro to drive the process from the last formfield or content control in that table. You will, of course, need to rename your formfields and modify your existing code to continue working with those. The advantage of using content controls, on the other hand, is that they don't require document protection to work (though that can be used) and don't require each new set to be renamed.

For code that works by adding a new row to a table in a document with formfields:
Macro to add row to table in a Word form

For code that works by adding a new row to a table in a document with content controls:
Code to add new row in table
Macro to add row to table in a Word form
https://www.msofficeforums.com/word-...tml#post145675
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #3  
Old 01-12-2020, 08:01 AM
NLJ NLJ is offline Dependent dropdown and repeat section Windows 10 Dependent dropdown and repeat section Office 2016
Novice
Dependent dropdown and repeat section
 
Join Date: Jan 2020
Posts: 5
NLJ is on a distinguished road
Default

Thank you for the advice and noting my misinformation. I'll do additional research on the basic cc/forms and then try to apply the advice you've given.

Are there any online courses or references that would be helpful to someone like me that knows nothing, but would like to learn more about VBA (word and excel)? I see this as a very powerful tool that I could apply for efficiency.

Thanks again
Reply With Quote
  #4  
Old 01-12-2020, 05:00 PM
macropod's Avatar
macropod macropod is offline Dependent dropdown and repeat section Windows 7 64bit Dependent dropdown and repeat section Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,956
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

I am not aware of any on-line courses that would be worthwhile. But, then, I also don't spend time reviewing them...
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
Reply

Tags
dependent vba

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Dependent dropdown and repeat section Content Controls - Dependent Dropdown someazguy Word VBA 14 02-05-2023 08:01 PM
Dependent dropdown and repeat section Multiple dependent dropdown lists in table with add new row option jeweldarby Word VBA 6 05-21-2022 04:37 PM
Dependent dropdown and repeat section Dropdown Menu Dependent on a Previous Drop Down lgsikaffy Word VBA 3 12-14-2018 05:14 PM
Dropdown dependent text JakeLRL Word VBA 7 04-07-2016 08:26 AM
make text form field active dependent on dropdown Glenn0004 Word VBA 1 06-23-2015 06:13 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 08:41 AM.


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