Results 1 to 8 of 8

Thread: Find Form Controls with Value not set

Threaded View

Previous Post Previous Post   Next Post Next Post
  1. #4
    VBAX Sage SamT's Avatar
    Joined
    Oct 2006
    Location
    Near Columbia
    Posts
    7,709
    Location
    THis won't work: Wrong Event
    Private Sub MultiPage1_Change()
    dim contr as object
    
        For Each contr In UserForm1.Controls
           If TypeName(contr) = "ComboBox" Then
                If contr.ListIndex = -1 Then  
                     MsgBox " you have incomplete answers"
                     Exit Sub
               End If
           End If
       Next
    End Sub
    Try this
    Option Explicit
    
    Private Sub CommandButtonX_Click()
    'Replace CommandButtonX with your button name.
    Dim Pg As Object, Ctrl As Object
    
        For Each Pg In MultiPage1.Pages
            For Each Ctrl In Pg.Controls
                If TypeName(Ctrl) = "ComboBox" Then
                    If Ctrl.ListIndex = -1 Then
                        MsgBox "You have incomplete answers on Page " & Pg.Caption
                        Pg.SetFocus 'Redundant
                        Ctrl.SetFocus
                        Exit Sub
                    End If
                End If
            Next
        Next
    End Sub
    Use the Go Advanced button to upload attachments
    Last edited by SamT; 06-02-2021 at 10:08 AM.
    Please take the time to read the Forum FAQ

Tags for this Thread

Posting Permissions

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