+ Reply to Thread
Results 1 to 27 of 27

Runtime error #1004 - Please advise

  1. #1
    Forum Contributor
    Join Date
    09-10-2008
    Location
    Phoenix, AZ
    MS-Off Ver
    Office 365
    Posts
    985

    Runtime error #1004 - Please advise

    Trying to create and update button to edit a record in a spreadsheet - the following code is being used - but when I select the row to update the area highlighted in red shows Runtime error #1004 - Application or Object defined error.

    Can anyone advise ?

    Please Login or Register  to view this content.
    Best Regards,

    John

  2. #2
    Forum Expert
    Join Date
    10-09-2014
    Location
    Newcastle, England
    MS-Off Ver
    2003 & 2013
    Posts
    1,986

    Re: Runtime error #1004 - Please advise

    you havent set the value of currentrow.

    If you're looking for the row thats active then you'll need Activecell.row

  3. #3
    Forum Guru Norie's Avatar
    Join Date
    02-02-2005
    Location
    Stirling, Scotland
    MS-Off Ver
    Microsoft Office 365
    Posts
    19,643

    Re: Runtime error #1004 - Please advise

    In the code you posted currentrow has no value.
    If posting code please use code tags, see here.

  4. #4
    Forum Contributor
    Join Date
    09-10-2008
    Location
    Phoenix, AZ
    MS-Off Ver
    Office 365
    Posts
    985

    Re: Runtime error #1004 - Please advise

    Please Login or Register  to view this content.
    still getting error - is there an example? -

    There are hundreds of records - I have a Listbox that shows the records in the userform - I want to update the record in the fields of the userform and then update the record with the button when complete
    Last edited by JJFletcher; 10-25-2014 at 04:41 PM. Reason: corrections

  5. #5
    Forum Expert
    Join Date
    10-09-2014
    Location
    Newcastle, England
    MS-Off Ver
    2003 & 2013
    Posts
    1,986

    Re: Runtime error #1004 - Please advise

    Please Login or Register  to view this content.
    alternatively, declare currentrow variable as the activecell.row which makes the changes to your code much smaller.

    Please Login or Register  to view this content.

  6. #6
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,364

    Re: Runtime error #1004 - Please advise

    Please Login or Register  to view this content.

    Regards, TMS
    Trevor Shuttleworth - Retired Excel/VBA Consultant

    I dream of a better world where chickens can cross the road without having their motives questioned

    'Being unapologetic means never having to say you're sorry' John Cooper Clarke


  7. #7
    Forum Contributor
    Join Date
    09-10-2008
    Location
    Phoenix, AZ
    MS-Off Ver
    Office 365
    Posts
    985

    Re: Runtime error #1004 - Please advise

    I have made the modifications - yet still get the error???

    error.JPG

  8. #8
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,364

    Re: Runtime error #1004 - Please advise

    I don't have a form, textbox or command button so I can't test YOUR code.

    But that line of code works. Not sure if it's because the Textbox is selected.

    Like I say, I can't test it. Suggest you post a sample workbook.

    Regards, TMS

  9. #9
    Forum Contributor
    Join Date
    09-10-2008
    Location
    Phoenix, AZ
    MS-Off Ver
    Office 365
    Posts
    985

    Re: Runtime error #1004 - Please advise

    Ok - I will Post

  10. #10
    Registered User
    Join Date
    03-12-2014
    Location
    India
    MS-Off Ver
    Excel 2003
    Posts
    41

    Re: Runtime error #1004 - Please advise

    Hello JJ Fletcher,

    I've revised your code. Please use the below code on a module and rename the worksheet as appropriate.

    Please Login or Register  to view this content.

  11. #11
    Forum Contributor
    Join Date
    09-10-2008
    Location
    Phoenix, AZ
    MS-Off Ver
    Office 365
    Posts
    985

    Re: Runtime error #1004 - Please advise

    HR Dashboard Master V3.xlsm

    This is the Workbook - I really appreciate your looking at it:

    When selecting the Add Data Button - the password is : " Password " without the quotes.

  12. #12
    Forum Contributor
    Join Date
    09-10-2008
    Location
    Phoenix, AZ
    MS-Off Ver
    Office 365
    Posts
    985

    Re: Runtime error #1004 - Please advise

    I received this error with the modifications you provided jayesh25

    Error3.JPG

  13. #13
    Registered User
    Join Date
    03-12-2014
    Location
    India
    MS-Off Ver
    Excel 2003
    Posts
    41

    Re: Runtime error #1004 - Please advise

    Sorry my bad. Didn't get a chance to test it. Typed it out via mobile.

    Could you change that to

    Please Login or Register  to view this content.

  14. #14
    Forum Contributor
    Join Date
    09-10-2008
    Location
    Phoenix, AZ
    MS-Off Ver
    Office 365
    Posts
    985

    Re: Runtime error #1004 - Please advise

    Jayesh25,

    Trying your code and the data in the fields in the Userform when they are changed do not update the record in the Listbox.. The record is updated - it is appended to the bottom of the spreadsheet - the actual record selected from the Listbox on the Userform is not updated - only added to the bottom of the sheet

    Probably you can look at the Workbook I sent up?

    John

  15. #15
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,364

    Re: Runtime error #1004 - Please advise

    Please Login or Register  to view this content.


    Regards, TMS

  16. #16
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,364

    Re: Runtime error #1004 - Please advise

    Maybe:

    Please Login or Register  to view this content.

    Regards, TMS

  17. #17
    Forum Contributor
    Join Date
    09-10-2008
    Location
    Phoenix, AZ
    MS-Off Ver
    Office 365
    Posts
    985

    Re: Runtime error #1004 - Please advise

    I tried this to the code and it deleted row 32 of the spreadsheet

    It did not make any modifications to the spreadsheet or the linkbox data

    Any Thoughts

  18. #18
    Forum Contributor
    Join Date
    09-10-2008
    Location
    Phoenix, AZ
    MS-Off Ver
    Office 365
    Posts
    985

    Re: Runtime error #1004 - Please advise

    TMS,

    I tried your code also - did not modify the data in the spreadsheet or the data in the textbox - once the update button was selected the data that was originally there simply reposted back

    Have you looked at the workbook sent uploaded?

  19. #19
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,364

    Re: Runtime error #1004 - Please advise

    Not sure why that would be. There's no code to delete anything.

    Rather than put the text box values into variables, and then setting the cell to the variable, it just does it directly ... no middle man.

    If you are making changes to the entries, I would expect you to have to re-initialise/reload the link box.

    Whatever, I think you need to fully qualify the cell, that is, use the worksheet name ... as shown in post #15

  20. #20
    Forum Contributor
    Join Date
    09-10-2008
    Location
    Phoenix, AZ
    MS-Off Ver
    Office 365
    Posts
    985

    Re: Runtime error #1004 - Please advise

    TMS,

    This is your code that was entered into the Userform.

    Please Login or Register  to view this content.
    I selected the top record in the textbox on the userform and it also is the first record in the spreadsheet that I am trying to modify and update. The information in the useform did not change - in fact it made no modification of the data in the userform textbox at all - and no change to the first record on the spreadsheet that was selected

    However,

    What did happed though once the information was modified on the userform and the Update button was selected - I went and looked at the spreadsheet because there were no changes visible on the userform textbox - the record being modified was duplicated at the bottom of the spreadsheet - 7 rows below the last record -INTERESTING!

    Any Thoughts

  21. #21
    Forum Guru
    Join Date
    03-02-2006
    Location
    Los Angeles, Ca
    MS-Off Ver
    WinXP/MSO2007;Win10/MSO2016
    Posts
    12,598

    Re: Runtime error #1004 - Please advise

    For the Update, Delete and some other functions, you must find the row of the employee record in the database. Activecell could be anywhere! If you are going to ADD a new record, then you must find the row of the last existing record, etc.
    Please Login or Register  to view this content.
    Last edited by protonLeah; 10-25-2014 at 08:39 PM.
    Ben Van Johnson

  22. #22
    Forum Contributor
    Join Date
    09-10-2008
    Location
    Phoenix, AZ
    MS-Off Ver
    Office 365
    Posts
    985

    Re: Runtime error #1004 - Please advise

    ProtonLeah,

    It worked perfect!!! Where have you been for the last three days - WOW!

    You did it! Thank you sooooo Much!

    One last question - you mention in your comment that Update, Delete and some other functions, you must find the row of the employee record in the database - can this code also be used to delete a record using the userform / textbox and also from the spreadsheet?

  23. #23
    Forum Contributor
    Join Date
    09-10-2008
    Location
    Phoenix, AZ
    MS-Off Ver
    Office 365
    Posts
    985

    [SOLVED]Re: Runtime error #1004 - Please advise

    Fantastic Job to all who helped!

    Great Contribution!

    John

  24. #24
    Forum Guru
    Join Date
    03-02-2006
    Location
    Los Angeles, Ca
    MS-Off Ver
    WinXP/MSO2007;Win10/MSO2016
    Posts
    12,598

    Re: Runtime error #1004 - Please advise

    The code:
    Set lACRow = .Range("A:A").Find(txtfullname.Text)
    tells you the row of the record highlighted in the listbox on the user form.
    For the DELETE function, you need code to select the entire row and delete it:
    Something like:

    .Range("A" & foundrow).entirerow.delete

    ---------------
    Your current code for the DELETE works but, if you use the .find function you can eliminate the For..Next/test loop.
    Last edited by protonLeah; 10-25-2014 at 10:46 PM.

  25. #25
    Forum Contributor
    Join Date
    09-10-2008
    Location
    Phoenix, AZ
    MS-Off Ver
    Office 365
    Posts
    985

    Re: Runtime error #1004 - Please advise

    I will try and create the code - If it fails I will post for help "LOL"

    Thanks!

  26. #26
    Forum Contributor
    Join Date
    09-10-2008
    Location
    Phoenix, AZ
    MS-Off Ver
    Office 365
    Posts
    985

    [SOLVED] Re: Runtime error #1004 - Please advise

    Thanks to all! - [SOLVED]

  27. #27
    Forum Guru TMS's Avatar
    Join Date
    07-15-2010
    Location
    The Great City of Manchester, NW England ;-)
    MS-Off Ver
    MSO 2007,2010,365
    Posts
    44,364

    Re: Runtime error #1004 - Please advise

    You're welcome.




    If you are satisfied with the solution(s) provided, please mark your thread as Solved.


    New quick method:
    Select Thread Tools-> Mark thread as Solved. To undo, select Thread Tools-> Mark thread as Unsolved.

    Or you can use this way:

    How to mark a thread Solved
    Go to the first post
    Click edit
    Click Go Advanced
    Just below the word Title you will see a dropdown with the word No prefix.
    Change to Solved
    Click Save


    You may also want to consider thanking those people who helped you by clicking on the little star at the bottom left of their reply to your question.

+ 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] VBA Error: Runtime Error 1004: AutoFilter method of Range class failed
    By jl22stac in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-03-2013, 07:27 PM
  2. [SOLVED] Range error in code, runs alone but not inside my full program, giving runtime error 1004
    By charizzardd in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-23-2012, 03:34 PM
  3. Runtime error 1004
    By fieldsy73 in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 02-23-2007, 09:19 AM
  4. runtime error 1004
    By valdesd in forum Excel General
    Replies: 0
    Last Post: 10-12-2005, 01:05 PM
  5. [SOLVED] Excel 2003 Macro Error - Runtime error 1004
    By Cow in forum Excel General
    Replies: 2
    Last Post: 06-07-2005, 09:05 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