Results 1 to 2 of 2

Thread: Initialized Dropdown Not Populating Doc

  1. #1

    Thread Starter
    Member
    Join Date
    Mar 2005
    Location
    SoCal
    Posts
    54

    Initialized Dropdown Not Populating Doc

    I have created an input form for a Word 2003 document that contains various dropdowns, option buttons & text boxes. These are in turn used to determine which string various docVariables inserted throughout the document will be assigned for their value.

    I initialized the all of these controls so that if the user misses one it won't generate an error in the document.

    However, just one of these dropdowns generates an error if I leave it as it is initialized. If I click in the dropdown, even without changing it, it does not generate an error. Can someone help me find my error?

    Code:
    Private Sub UserForm_Initialize()
    
    'Populate the dropdowns
        With Input_Selections
                    
            StatusList.AddItem "single"
            StatusList.AddItem "widow"
            StatusList.AddItem "widower"
            
            NumKidsList.AddItem "zero (0)"
            NumKidsList.AddItem "one (1)"
            '...
    
            'Set Default for Dropdowns
            StatusList.Value = "single"
            NumKidsList.Value = "zero (0)"
            '...        
            
            TrustBox.SetFocus
                                    
        End With
                
    End Sub
    
    Private Sub SubmitBtn_Click()
    
    '...
    Dim StatusStr As String
    '...
    Dim NumKidsStr As String
    Dim NameKidsStr As String
    '...
    
    'Populate number of children
    'This boolean tests whether children have ever lived to populate a single entry in the doc
    OptKidB = False
    NumKidsStr = NumKidsList.Value
    
    'ActiveDocument.Variables.Add Name:="NumKidsV", Value:=" "
    'ActiveDocument.Variables.Add Name:="KidNamesV", Value:=" "
    
    If NumKidsList.Value = "zero (0)" Then
            
        'No kids so terminate sentence in doc
        NameKidsStr = ".  "
            
        Else
        
            OptKidB = True
        
            NameKidsStr = "namely, "
        
            Dim TotalKids As Integer
            Dim i As Integer
        
            TotalKids = NumKidsList.ListIndex
         
            'Kids names filled in by looping through names & dob array.  If end
            'of array, period added.  If not, semicolon added
            For i = 0 To TotalKids
        
                NameKidsStr = NameKidsStr & KidNameArray(i) & ", born " & KidDOBArray(i)
            
                If i = TotalKids Then
            
                    NameKidsStr = NameKidsStr & ".  "
                
                    Else
                
                        NameKidsStr = NameKidsStr & "; "
                End If
            
            Next i
            
    End If
    
    ActiveDocument.Variables("NumKidsV").Value = NumKidsStr
    ActiveDocument.Variables("KidNamesV").Value = NameKidsStr

  2. #2

    Thread Starter
    Member
    Join Date
    Mar 2005
    Location
    SoCal
    Posts
    54

    Re: Initialized Dropdown Not Populating Doc

    I'm just checking back in to see if anyone has had a similar issue or knows where my error is.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width