+ Reply to Thread
Results 1 to 13 of 13

vba excel - Parental control multipage userform runtime error 438

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

    vba excel - Parental control multipage userform runtime error 438

    I receive a 438 error with this code. It was working before, but since I've added more controls and am ready to publish the userform, I have received this error.
    Please Login or Register  to view this content.
    I thought it may have to do with disabled and/or invisible text boxes, but after enabling and making them visible, it still errors. I've made a test file and deleted every control except one on each multipage, and it still errors. Does anybody have any suggestions?

  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

    Setting up a standard multipage with a few pages and various controls I could not get the line to error.
    Userforms can be complex in design but having said that you are specifically targetting textboxes anyway.

    What is the purpose of the line? It does not appear to achieve anything and Setfocus took me to the textbox with no data ready for input.

    You mention hidden and/or disabled textboxes and to avoid Setfocus errors I would suggest you amend the line
    If Ctrl.Value = "" to
    If Ctrl.Value = "" And Ctrl.Visible = True And Ctrl.Enabled = True Then

  3. #3
    Valued Forum Contributor Maudibe's Avatar
    Join Date
    12-21-2016
    Location
    USA
    MS-Off Ver
    2010-2013
    Posts
    326

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

    Terriertrip,

    This error will be thrown if you have an additional textbox on the userform outside of the multipage control. Could this be the case?

    HTH,
    Maud

  4. #4
    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

    That would be the case. Would I have to create two sets of code for each case?

  5. #5
    Valued Forum Contributor Maudibe's Avatar
    Join Date
    12-21-2016
    Location
    USA
    MS-Off Ver
    2010-2013
    Posts
    326

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

    No, this should do it

    Please Login or Register  to view this content.
    HTH,
    Maud

  6. #6
    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

    What is the purpose of the line? It does not appear to achieve anything and Setfocus took me to the textbox with no data ready for input.
    From what I've learned, parent of the control is the Page it is on and the Parent of the Control's Parent is the Multipage container object.
    There are controls that aren't on on the mulitpage and any other control (within the mulitpage) that is not a textbox has its own targeted code. Only the text boxes are the focus of this line since those are the only area where the unpredictability of user procedures can occur (for the most part) - hence prohibiting empty controls. I've eliminated the the hidden and/or disabled textboxes and the error still occurs, so I'm not sure if the appended code would make a difference.

  7. #7
    Forum Expert mikerickson's Avatar
    Join Date
    03-30-2007
    Location
    Davis CA
    MS-Off Ver
    Excel 2011
    Posts
    6,229

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

    If I were you I would write three branches of code.
    1) to deal with a text box on a MultiPages' Page
    2) to deal with a textbox in a frame.
    3) to deal with a textbox on the UF, outside of a frame or a MultiPage.

    Something like

    Please Login or Register  to view this content.
    _
    ...How to Cross-post politely...
    ..Wrap code by selecting the code and clicking the # or read this. Thank you.

  8. #8
    Valued Forum Contributor Maudibe's Avatar
    Join Date
    12-21-2016
    Location
    USA
    MS-Off Ver
    2010-2013
    Posts
    326

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

    From what I've learned, parent of the control is the Page it is on and the Parent of the Control's Parent is the Multipage container object.
    You are correct above. The added condition will inhibit execution if the Parent of the parent is not the Multipage therefore, any controls that are not textboxes and/or beyond the multipage would be excluded. The code should work as is however, the wisdom of mikerickson is something that you may not want to overlook.

    Maud

  9. #9
    Forum Guru xlnitwit's Avatar
    Join Date
    06-27-2016
    Location
    London
    MS-Off Ver
    Windows: 2010; Mac: 16.13 (O365)
    Posts
    7,085

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

    Hi,

    Why not simply loop through the pages of the multipage and through the Controls collection of each, if those are the only controls you are interested in?
    Don
    Please remember to mark your thread 'Solved' when appropriate.

  10. #10
    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!):
    Please Login or Register  to view this content.
    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

  11. #11
    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:

    Please Login or Register  to view this content.
    hth
    Last edited by Ozex; 10-09-2017 at 03:57 PM.

  12. #12
    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

    Thanks Ozex. Works perfectly. I appreciate your help.

  13. #13
    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

    Glad to help terriertrip. Form management can be frustrating at times.

+ 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