+ Reply to Thread
Results 1 to 7 of 7

Delete/update record using Excel form

  1. #1
    Registered User
    Join Date
    06-02-2009
    Location
    Toronto
    MS-Off Ver
    Excel 2010
    Posts
    75

    Smile Delete/update record using Excel form

    Hi,

    I am half way through the problem!!
    I developed a user form to populate records through a list box. The user selects a record from the list box.
    The selected record shows up at the bottom of the form allowing the user to make changes.
    I need to program the two command buttons to update the record in the database, and o delete the record from the database.
    Both buttons highlighted in "yellow" in the attached file (below)
    I appreciate your help.. Thanks

    DataEntry.xlsm

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

    Re: Delete/update record using Excel form

    Hi adelkam,

    See if the creation of a Global Variable helps tie your listbox to the rows of the sheet. I think I've fixed your code. You may need to format the date in the update click.
    Attached Files Attached Files
    One test is worth a thousand opinions.
    Click the * Add Reputation below to say thanks.

  3. #3
    Registered User
    Join Date
    06-02-2009
    Location
    Toronto
    MS-Off Ver
    Excel 2010
    Posts
    75

    Re: Delete/update record using Excel form

    Thanks MarvinP

    It appears that the delete only works, The update does not work..
    The update should be reflected in the "Database" worksheet, then it will be shown in the list box automatically (as the delete). For some reason it does not work at my end..
    I added more code to the update button for the remaining text boxes. I uploaded the file again, I appreciate if you can review..

    Thanks again

    375461-delete-update-record-using-excel-form-userform-tie-to-dnr-so-lists-match-REV2.xlsm

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

    Re: Delete/update record using Excel form

    OK, after a lot of study and trial and error here is what I find.

    As soon as a single cell is changed on the worksheet the code jumps to the lstProjects_Click() event. This then puts all the old values in the Frame6 cells.

    I believe this is a problem with Event Scope. Read http://www.cpearson.com/excel/Scope.aspx

    The idea is that the code in a userform is supposed to only work in/on that userform. Good programmers write code in Modules and then have the Event Code in the userform call the Module code.

    I have another idea that I hate to suggest but may work for you. It is called the Form.. Dialog/Icon that is already in Excel and simply not displayed on the toolbar, as it is an older tool.
    http://www.addintools.com/documents/...data-form.html

    I worked on this for about an hour and couldn't ferret it out. Sorry.
    Attached Files Attached Files
    Last edited by MarvinP; 02-06-2015 at 01:42 AM.

  5. #5
    Forum Expert snb's Avatar
    Join Date
    05-09-2010
    Location
    VBA
    MS-Off Ver
    Redhat
    Posts
    5,649

    Re: Delete/update record using Excel form

    Last edited by snb; 02-07-2015 at 09:36 AM.



  6. #6
    Forum Expert Vikas_Gautam's Avatar
    Join Date
    06-04-2013
    Location
    Ludhiana,Punjab, India
    MS-Off Ver
    Excel 2013
    Posts
    1,850

    Re: Delete/update record using Excel form

    This is done...!!!!

    I have explained my technique in the code itself. So do check it to understand.

    Check the attached file:-
    Attached Files Attached Files
    Last edited by Vikas_Gautam; 03-24-2015 at 12:56 PM.
    Regards,
    Vikas Gautam
    Excel-buzz.blogspot.com

    Excel is not a matter of Experience, its a matter of Application.

    Say Thanks, Click * Add Reputation

  7. #7
    Forum Expert Vikas_Gautam's Avatar
    Join Date
    06-04-2013
    Location
    Ludhiana,Punjab, India
    MS-Off Ver
    Excel 2013
    Posts
    1,850

    Re: Delete/update record using Excel form

    In brief:-
    What I have done is to bypass Listbox_Click event while updating the record. I have done this by using an Extra variable(Ind) at Module Scope to hold the Row No. Under update. When Listbox_Click Event gets active, it check if current row num matches with Ind. If same then bypasses the event (means exits Listbox_click Sub).

+ 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. Update Current Record from Form
    By larrysdime in forum Excel Programming / VBA / Macros
    Replies: 4
    Last Post: 02-09-2015, 09:34 PM
  2. [SOLVED] Open a new form, create new record based on current form / record
    By Cyclops in forum Access Tables & Databases
    Replies: 4
    Last Post: 01-28-2013, 06:36 PM
  3. User Form to Retrieve then Update specific record
    By jimrood in forum Excel Programming / VBA / Macros
    Replies: 0
    Last Post: 10-21-2012, 02:03 PM
  4. Update/Delete a Record in an Access 2010 Database using Excel VBA
    By tomlancaster in forum Excel Programming / VBA / Macros
    Replies: 2
    Last Post: 03-15-2012, 12:36 PM
  5. Delete record in Access 2003 form
    By rlsublime in forum Access Programming / VBA / Macros
    Replies: 1
    Last Post: 03-02-2012, 03:29 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