+ Reply to Thread
Results 1 to 9 of 9

From a UserForm, Update data command button is not working

  1. #1
    Forum Contributor
    Join Date
    11-30-2012
    Location
    Colorado, US
    MS-Off Ver
    MS Prof. 2010 and 2013 + 365
    Posts
    113

    From a UserForm, Update data command button is not working

    I feel dumb asking/posting this question, but I just can't get it resolved. Your input will be greatly appreciated.
    I have created a UserForm with about 90 fields, comprised of textboxes, comboboxes and checkboxes.
    In this UserForm, the user can select a name in the 1st field (the txtfname box) and click on "Find" and the form populates with the correct data, in all boxes. This is working fine.
    The user can also select to Clear the form and enter new data by clicking on "Add New Record", and this is also working well, as new records are added to the database.
    The search features in the UserForm, to "Find Next" or "Find Previous" records are also working swimmingly.
    What is not working is the "Update" button. (see code below).
    It doesn't do anything, or when it does, it creates a new record by overwriting the headers in the database sheet.
    Any suggestions?

    Thank you.









    Please Login or Register  to view this content.

  2. #2
    Forum Guru MarvinP's Avatar
    Join Date
    07-23-2010
    Location
    Woodinville, WA
    MS-Off Ver
    Office 365
    Posts
    16,167

    Re: From a UserForm, Update data command button is not working

    Hi John,

    Based on your description of what it does, overwrites the header....

    I'd suggest that your userform shows data from the rows and columns in your database. If you open the userform and your cursor is on cell B7 then that might be the row (row 7) that it thinks it is to write your userform data.

    I believe you need to somewhere in your userform set the row that is the active/selected cell on the worksheet.
    Something like
    currentrow = ActiveCell.Row or

    Step thought your code and see what value Currentrow is equal to and you will find where your data is going.
    If you find next or previous, soon after that you need to tell the userform what row you are on.... Set currentrow at that time.

    Also, I think you can reduce/improve your code using a "With" construct like the below
    Please Login or Register  to view this content.
    I hope this helps.
    Last edited by MarvinP; 03-03-2015 at 10:35 PM.
    One test is worth a thousand opinions.
    Click the * Add Reputation below to say thanks.

  3. #3
    Forum Contributor
    Join Date
    11-30-2012
    Location
    Colorado, US
    MS-Off Ver
    MS Prof. 2010 and 2013 + 365
    Posts
    113

    Re: From a UserForm, Update data command button is not working

    Thanks Marvin, for your feedback.
    The issue is, the user can't select an active row on the worksheet "DB", because they will not be able to see the worksheet (which is hidden and acts like a database). The UserForm has to find that row, based on the selection made in the "fname" field.
    I think it would help you to clarify if I could show you all the code for my userform, but it exceeds the 15,000 characters allowed on this forum.
    Once I fix the Update issue, I'd like to learn more about, and try the "With" construct as you suggested, and simplify and clean up my code.

    In the meantime, am eagerly awaiting your reply.
    Last edited by johnw993; 03-04-2015 at 01:00 AM.

  4. #4
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: From a UserForm, Update data command button is not working

    Hi John

    Create a new (can be hidden) textbox (call it say tbNameRow) on your User Form and populate it with Row Number of the Name found by the Find Code.

    Then add this Code
    Please Login or Register  to view this content.
    John

    If you have issues with Code I've provided, I appreciate your feedback.

    In the event Code provided resolves your issue, please mark your Thread as SOLVED.

    If you're satisfied by any members response to your issue please use the star icon at the lower left of their post.

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

    Re: From a UserForm, Update data command button is not working

    Where/how/when are you setting the value of currentrow?
    If posting code please use code tags, see here.

  6. #6
    Forum Contributor
    Join Date
    11-30-2012
    Location
    Colorado, US
    MS-Off Ver
    MS Prof. 2010 and 2013 + 365
    Posts
    113

    Re: From a UserForm, Update data command button is not working

    Thank you JasLake, this solved the problem!

  7. #7
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: From a UserForm, Update data command button is not working

    You're welcome...glad I could help.

    If you're satisfied by any members response to your issue please use the star icon at the lower left of their post.

  8. #8
    Forum Contributor
    Join Date
    11-30-2012
    Location
    Colorado, US
    MS-Off Ver
    MS Prof. 2010 and 2013 + 365
    Posts
    113

    Re: From a UserForm, Update data command button is not working

    JasLake, I have a different question:
    I'm struggling with replacing the DTPicker function in my WorkBook and UserForms. I found and downloaded your frmCalendarv.102.zip file and have installed it in the workbook and it is working great! in all the worksheets.
    How can I make this work the same way in UserForms?
    I think I may be able to figure it out by experimenting, but it would be helpful if you have an 'easy' and elegant answer.

    Thank you!
    John
    Last edited by johnw993; 03-05-2015 at 05:35 PM.

  9. #9
    Forum Expert jaslake's Avatar
    Join Date
    02-21-2009
    Location
    Atwood Lake in Mid NE Ohio...look it up.
    MS-Off Ver
    Excel 2010 2019
    Posts
    12,749

    Re: From a UserForm, Update data command button is not working

    Hi John

    A couple things...

    Firstly, this is NOT my Code...I copped it from the Internet...probably here but I'd not swear to it.
    http://excel-it.com/excel_datepickers.html

    Secondly, this is a new Issue and should be the Subject of a new Thread such that you'll get attention from all the helpers on this Forum. Not many will look at a SOLVED Thread. You may PM me with a Link to your new Thread if you wish.

    And thirdly, if you truly wish help with the Date Picker issue, you'll need to upload a sanitized version of your File so we can see what you have and what you need.

    Alternately, here's a link that demonstrates the Calendar Control on a User Form (Post #3).
    http://www.excelforum.com/excel-prog...userforms.html

    Let me know how I can help.
    Last edited by jaslake; 03-05-2015 at 06:59 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. [SOLVED] Using command button in userform to update current row
    By puffo in forum Excel Programming / VBA / Macros
    Replies: 3
    Last Post: 08-07-2014, 03:32 PM
  2. Coding Search and Update Command Button in an UserForm
    By sottojeromey in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 10-25-2013, 06:39 AM
  3. [SOLVED] getting data from command button in userform why is my code not working?
    By Curious2 in forum Excel Programming / VBA / Macros
    Replies: 18
    Last Post: 06-07-2013, 10:37 AM
  4. [SOLVED] Excel vba userform - code for command button not working
    By PANTECH in forum Excel Programming / VBA / Macros
    Replies: 1
    Last Post: 04-26-2013, 11:27 AM
  5. UserForm, update after command button click
    By ker9 in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 11-01-2010, 01:05 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