+ Reply to Thread
Results 1 to 13 of 13

vba excel - Parental control multipage userform runtime error 438

Hybrid View

  1. #1
    Forum Contributor
    Join Date
    02-25-2013
    Location
    Colorado, US
    MS-Off Ver
    Microsoft 365 Apps
    Posts
    518

    Re: vba excel - Parental control multipage userform runtime error 438

    All right. I thought I was gettin somewhere. Thank you mikerickson for the suggestion. Using Type(Ctrl) vba gives me a compile error expected: expression so I changed it to TypeName(Ctrl) and the compile error resolved. However, even though I ran the below code and worked as intended (even following the tab order!):
    For Each Ctrl In Controls
        If TypeName(Ctrl) = "Textbox" Then
            Select Case TypeName(Ctrl.Parent)
                Case "Page"
                    If Ctrl.Value = "" Then
                        Ctrl.BackColor = vbYellow
                        Ctrl.Parent.Parent.Value = Ctrl.Parent.Index
                        Ctrl.SetFocus
                        MsgBox Ctrl.Name & " is required.", vbOKOnly, "Missing Item"
                        Exit Sub
                    End If
                Case Else
                    If Ctrl.Value = "" Then
                        Ctrl.BackColor = vbYellow
                        MsgBox Ctrl.Name & " is required.", vbOKOnly, "Missing Item"
                        Ctrl.SetFocus
                        Exit Sub
                    End If
            End Select
        End If
    Next Ctrl
    It errored (now 2110) on the Ctrl.SetFocus because there are also comboboxes on the form as well (I know just enough that obviously it's going to error due to the typename constraint). I do have a branch of code to deal with empty comboboxes. Even more odd to me, after that error, now when I run the code , the code no longer executes. It bypasses and goes straight to my msgbox. I shut down the application and it still no longer executes the code. I feel like I'm falling deeper into the rabbit hole on this

  2. #2
    Registered User
    Join Date
    10-07-2017
    Location
    Perth, Down Under
    MS-Off Ver
    2016
    Posts
    45

    Re: vba excel - Parental control multipage userform runtime error 438

    Have you tried something like this:

        For Each Ctrl In Controls
            If TypeOf Ctrl Is msforms.TextBox Then
                If TypeOf Ctrl.Parent Is msforms.Page Then
                    If Ctrl.Value = "" And Ctrl.Visible = True And Ctrl.Enabled = True Then
                        Ctrl.BackColor = vbYellow
                        Ctrl.Parent.Parent.Value = Ctrl.Parent.Index
                        Ctrl.SetFocus
                        MsgBox Ctrl.Name & " is required.", vbOKOnly, "Missing Item"
                        Exit Sub
                    End If
                Else
                    If Ctrl.Value = "" And Ctrl.Visible = True And Ctrl.Enabled = True Then
                        Ctrl.BackColor = vbYellow
                        MsgBox Ctrl.Name & " is required.", vbOKOnly, "Missing Item"
                        Ctrl.SetFocus
                        Exit Sub
                    End If
                End If
            End If
        Next Ctrl
    hth
    Last edited by Ozex; 10-09-2017 at 03:57 PM.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Similar Threads

  1. Replies: 1
    Last Post: 03-08-2016, 08:47 PM
  2. [SOLVED] Repositioning a Commandbutton in a UserForm multipage control
    By newbi004 in forum Excel Programming / VBA / Macros
    Replies: 13
    Last Post: 04-27-2014, 09:52 AM
  3. [SOLVED] ActiveControl - Return non-Multipage control when Form contains Multipage?
    By mc84excel in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 03-04-2014, 08:37 PM
  4. [SOLVED] Userform multipage control exit events code execution not completed before next user entry
    By jane serky in forum Excel Programming / VBA / Macros
    Replies: 6
    Last Post: 06-10-2013, 04:39 AM
  5. Userform Multipage User Control Lock
    By gsurge in forum Excel Programming / VBA / Macros
    Replies: 5
    Last Post: 05-23-2011, 10:25 AM
  6. add a second layer to multipage control on userform
    By smokebreak in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 03-02-2011, 05:14 PM
  7. Reference Userform Multipage Control
    By kingdt in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 04-03-2010, 06:31 AM

Bookmarks

Posting Permissions

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

Search Engine Friendly URLs by vBSEO 3.6.0 RC 1