+ Reply to Thread
Results 1 to 5 of 5

Userform Run-time error 1004

  1. #1
    Forum Contributor
    Join Date
    09-21-2015
    Location
    nederland
    MS-Off Ver
    2021
    Posts
    203

    Userform Run-time error 1004

    Dear mr / mrs,

    I get run-time error 1004 when I try to delete data with cmdDelete see below the VBA

    Rowsource listbox1 = information

    please help me to resolve this issue
    thank you in advance for your support

    Kirana

    Please Login or Register  to view this content.
    Attached Files Attached Files
    Last edited by kirana2014; 11-28-2017 at 01:44 AM.

  2. #2
    Forum Expert gmr4evr1's Avatar
    Join Date
    11-24-2014
    Location
    Texas
    MS-Off Ver
    Office 2010 and 2007
    Posts
    3,448

    Re: Userform Run-time error 1004

    It has to do with this line
    Please Login or Register  to view this content.
    in the "ListBox1_Click" macro. If I comment out this line, it works fine.
    The error states that an application or object hasn't been defined

    More info: I stepped through the code and noticed that when the delete code runs, after it does this line....
    Please Login or Register  to view this content.
    it runs back through the ListBox1_Click code. At this point the range you want to activate has already been activated so it errors??
    Last edited by gmr4evr1; 11-26-2017 at 03:31 PM. Reason: Added more info
    1N73LL1G3NC3 15 7H3 4B1L17Y 70 4D4P7 70 CH4NG3 - 573PH3N H4WK1NG
    You don't have to add Rep if I have helped you out (but it would be nice), but please mark the thread as SOLVED if your issue is resolved.

    Tom

  3. #3
    Forum Expert
    Join Date
    10-06-2017
    Location
    drevni ruchadlo
    MS-Off Ver
    old
    Posts
    2,151

    Re: Userform Run-time error 1004

    As gmr4evr1 above, and and additionally:
    1. After deleting a row, 'ListBox1_Click' procedure runs 2x/works twice and fills the text boxes
    2. Why, since after returning, to the 'cmdDelete_Click' procedure, text boxes are clearing ?
    3. You haven't 'UserForm_Initialize' procedure
    According to me, you should add 'UserForm_Initialize' and improve the triggering of procedures (to prevent multiple runs).
    You could add e.g.:
    Please Login or Register  to view this content.
    and modify 'cmdDelete_Click', e.g.:
    Please Login or Register  to view this content.
    Last edited by mjr veverka; 11-26-2017 at 04:03 PM.

  4. #4
    Forum Expert
    Join Date
    12-14-2012
    Location
    London England
    MS-Off Ver
    MS 365 Office Suite.
    Posts
    8,448

    Re: Userform Run-time error 1004

    gmr4evr1 is right.

    In this type of scenario

    I Declare a public ChangeFlag as Boolean

    I then set ChangeFlag as True before I perform a function that could create an error

    I then set this back to False when I know that the risk of error has passed.

    This code works:-

    Please Login or Register  to view this content.
    My General Rules if you want my help. Not aimed at any person in particular:

    1. Please Make Requests not demands, none of us get paid here.

    2. Check back on your post regularly. I will not return to a post after 4 days.
    If it is not important to you then it definitely is not important to me.

  5. #5
    Forum Contributor
    Join Date
    09-21-2015
    Location
    nederland
    MS-Off Ver
    2021
    Posts
    203

    Re: Userform Run-time error 1004

    Dear all,

    Thank you for you help

    Kirana

+ 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. [SOLVED] I am getting error as "Run Time error '1004' Microsoft excel cannot paste the data
    By Amittapre in forum Excel Programming / VBA / Macros
    Replies: 43
    Last Post: 03-24-2017, 04:40 PM
  2. [SOLVED] Sort Macro Run-time error '1004': Application/Object-defined error.
    By sam1212 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 08-22-2014, 10:05 AM
  3. Run time error 1004 on userform initialize
    By Nitefox in forum Excel Programming / VBA / Macros
    Replies: 7
    Last Post: 03-09-2014, 12:44 PM
  4. Error "run-time Error '1004': General Odbc Error
    By D4WNO77 in forum Access Tables & Databases
    Replies: 2
    Last Post: 07-16-2012, 09:55 AM
  5. Fix Userform IF Statement - Run Time Error "1004"
    By sawan202 in forum Excel General
    Replies: 2
    Last Post: 03-07-2012, 06:32 AM
  6. Run time error 1004-created a userform
    By scrupo in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 03-23-2010, 04:11 AM
  7. Run-time error 1004 when trying to load UserForm
    By jasoncw in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 10-22-2008, 04:28 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