+ Reply to Thread
Results 1 to 12 of 12

Issue opening (showing) a userform

  1. #1
    Forum Contributor
    Join Date
    09-02-2013
    Location
    London
    MS-Off Ver
    Excel 2019
    Posts
    368

    Issue opening (showing) a userform

    Hello,
    I'm trying to Show (open) a userform as per the macro below but it gives me an Run Time error: 1004 Application-defined or Object-defined Error.
    Do you think there is a clash? this is supposed to be a straightforward macro.
    Please Login or Register  to view this content.
    Your help is much appreciated.

  2. #2
    Forum Moderator davesexcel's Avatar
    Join Date
    02-19-2006
    Location
    Regina
    MS-Off Ver
    MS 365
    Posts
    13,483

    Re: Issue opening (showing) a userform

    The problem is possibly in the userform.

    You don't indicate what line is yellow, but I assume it would be "invrec_frm.Show".

    Supply a sample workbook with the offending userform so somebody can find the problem for you

  3. #3
    Forum Contributor
    Join Date
    09-02-2013
    Location
    London
    MS-Off Ver
    Excel 2019
    Posts
    368

    Re: Issue opening (showing) a userform

    Hi davesexcel,
    You are indeed right. it's that 'invrec_frm.Show' that is highlighted in yellow.
    But I think the issue lies in the initialisation of the userform, that is, Userform.Initialize.
    With this Sub, it will copy and paste data from a dynamic named range from a worksheet. However, that named range has yet no data in it, and as a result somehow when we open (show) the userform, it goes to that error.
    I haven't figured yet how to resolve the issue but I reckon I should either use on error GoTo or if (named) range is empty Then ...

  4. #4
    Forum Contributor
    Join Date
    09-02-2013
    Location
    London
    MS-Off Ver
    Excel 2019
    Posts
    368

    Re: Issue opening (showing) a userform

    Hello,
    This is the macro for the initialisation, which may be at the heart of the issue.
    If the dynamic range is not empty then it will pull out the data as intended. However, as it is a new range with no data then it comes back as an error while trying to execute.
    Please Login or Register  to view this content.
    Can you please help?
    Thank you

  5. #5
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365, varying versions/builds
    Posts
    21,256

    Re: Issue opening (showing) a userform

    You could try something like:

    Please Login or Register  to view this content.
    Remember what the dormouse said
    Feed your head

  6. #6
    Forum Contributor
    Join Date
    09-02-2013
    Location
    London
    MS-Off Ver
    Excel 2019
    Posts
    368

    Re: Issue opening (showing) a userform

    Hi rorya, (The Eton Rifles is definitely a song with a brilliant lyrics).

    I think your rewrite suggestion works but when I now try to open the userform that will be initialised, nothing show up which should be the case. However, when the range is not empty - that is, has some data in it - it still doesn't show.

    How should I address that please?

    Thank you.

  7. #7
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365, varying versions/builds
    Posts
    21,256

    Re: Issue opening (showing) a userform

    Might be time for a workbook...

  8. #8
    Forum Contributor
    Join Date
    09-02-2013
    Location
    London
    MS-Off Ver
    Excel 2019
    Posts
    368

    Re: Issue opening (showing) a userform

    As requested,

    I guess it won't make sense to open(show) the form when the database range is empty but it would be good to handle the error nonetheless.

    If you populate the first row of the worksheet, the form will open when you click on the Update button.

    Thank you.
    Attached Files Attached Files

  9. #9
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365, varying versions/builds
    Posts
    21,256

    Re: Issue opening (showing) a userform

    I'm not seeing what you're seeing. If I put that code in, the listbox is populated if I enter an invoice number onto the sheet.

  10. #10
    Forum Contributor
    Join Date
    09-02-2013
    Location
    London
    MS-Off Ver
    Excel 2019
    Posts
    368

    Re: Issue opening (showing) a userform

    Now, that doesn't make sense. I swear to God, I used your code in and it didn't open even with something.
    Let me check something ....
    Apologies.

  11. #11
    Forum Contributor
    Join Date
    09-02-2013
    Location
    London
    MS-Off Ver
    Excel 2019
    Posts
    368

    Re: Issue opening (showing) a userform

    Quote Originally Posted by rorya View Post
    I'm not seeing what you're seeing. If I put that code in, the listbox is populated if I enter an invoice number onto the sheet.
    Silly me rorya. I was on a debug setting and that's why it didn't show up. Once again, my apologies and thank you very much for your help.

  12. #12
    Forum Expert romperstomper's Avatar
    Join Date
    08-13-2008
    Location
    East Sussex, UK
    MS-Off Ver
    365, varying versions/builds
    Posts
    21,256

    Re: Issue opening (showing) a userform

    Glad to help.

+ 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. Add-Ins not showing, Personal not opening
    By jomili in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 10-14-2018, 07:16 AM
  2. Issue opening multiple hyperlinks from Excel via Userform
    By chrisellis250 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 02-16-2018, 06:43 AM
  3. [SOLVED] Showing UserForm to Indicate Progress, Macro Doesn't Run Until I Exit UserForm
    By EnigmaMatter in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 11-21-2014, 07:00 PM
  4. Opening excel file showing userform
    By Paul Cherian in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 06-10-2014, 08:16 AM
  5. [SOLVED] userform opening on sheet2 but not showing combobox data values
    By KK1234 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 01-12-2014, 08:29 AM
  6. Opening workbook from userform keeping userform at background..
    By cooldude113322 in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 10-05-2012, 12:14 PM
  7. showing the userform again when userform hasn't been hidden or unloaded
    By stanigator in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 12-10-2007, 09:33 PM

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