+ Reply to Thread
Results 1 to 6 of 6

Code not updating the right record, allowing multiple records with same unique ID, HELP!!

  1. #1
    Registered User
    Join Date
    08-06-2012
    Location
    Lisbon, Portugal
    MS-Off Ver
    Excel 2007
    Posts
    5

    Code not updating the right record, allowing multiple records with same unique ID, HELP!!

    I desperately need your help.

    This is an excel wks designed for data entry in sheet "Input", data storage in sheet "PartsData".

    "Order ID" is supposed not to allow duplicates. When a new record is inserted with an existing Order_ID, user is asked if he wants to update existing record.

    BUG? -- As you can see in "PartsData", im starting off with 4 records (order_ID s 10100, 10101, 10102 and 10103). If i try to insert a new record in "Input" wks with Order_ID 10100 but with different values for "Part", "Location" and "Quantity", Excel tells me that that's an existing order_ID and asks if i want to UPDATE the existing record. I say YES.

    RESULT -- Excel does NOT UPDATE the original Order_ID=1100 record, instead it creates ANOTHER Order_ID=1100 record OVERWRITING the previously existing Order_ID=10102 record. I lose one record and get a new record

    Can someone tell me what's wrong? I need this corrected, as i was adapting this code for a work project, and know nothing about VBA... Thank you so much! - Joćo V.
    Attached Files Attached Files

  2. #2
    Registered User
    Join Date
    08-06-2012
    Location
    Lisbon, Portugal
    MS-Off Ver
    Excel 2007
    Posts
    5

    Re: Code not updating the right record, allowing multiple records with same unique ID, HEL

    Can someone please help?

  3. #3
    Registered User
    Join Date
    08-06-2012
    Location
    Lisbon, Portugal
    MS-Off Ver
    Excel 2007
    Posts
    5

    Re: Code not updating the right record, allowing multiple records with same unique ID, HEL

    As you can see, when Excel UPDATES a record (Order_ID already existed), it SIMPLY OVERWRITES THE THIRD RECORD, everytime. Adding a new record (Order_ID not previously existed) seems to work fine...

    How do i fix the VBA code?.... Im completely helpless.

  4. #4
    Forum Expert MickG's Avatar
    Join Date
    11-23-2007
    Location
    Banbury,Oxfordshire
    Posts
    2,650

    Re: Code not updating the right record, allowing multiple records with same unique ID, HEL

    In sheet "Input", Name the cell "D6", "Part" (NB:- it has the ref name ("Part") next to it.
    ,You can do this by selecting that cell, then go to the "Name Box" (Top left of window+ Type in the Box the word :- Part , then click Return'
    Also Change the formula in Cell named "CheckId" (L3) to the below.
    Please Login or Register  to view this content.
    That worked for me, and allowed me to Add the same Order number , but with different parts.
    Not sure if its a complete solution, but its a start !!!!
    Regards Mick
    Last edited by MickG; 08-06-2012 at 09:20 AM.

  5. #5
    Registered User
    Join Date
    08-06-2012
    Location
    Lisbon, Portugal
    MS-Off Ver
    Excel 2007
    Posts
    5

    Re: Code not updating the right record, allowing multiple records with same unique ID, HEL

    Thank you. Im still having trouble translating the excel formulas to portuguese. Im getting an error message.

    But tell me this: i don't want to be able to insert a record with an Order_ID i already have in my history (PartsData)... when i try to insert an already existing Order_ID, i want the macro to ask me if i want to UPDATE the existing record, and if i say YES, i want the old record to be replaced (ie: all fields with different values from the existing ones must change to the new values). In other words: whatever happens, i never want more than 1 instance of the same Order_ID in my data collection.

    From what i understand, im guessing youre making a combination of two fields (Order_ID + Part) to be the database key, and i need the database key to be ORDER_ID... Can you help? J

  6. #6
    Registered User
    Join Date
    08-06-2012
    Location
    Lisbon, Portugal
    MS-Off Ver
    Excel 2007
    Posts
    5

    Re: Code not updating the right record, allowing multiple records with same unique ID, HEL

    I just wrote back to the original code author, and sent her this link (2 Excel files and my note requesting help): https://www.sugarsync.com/pf/D8722812_66980811_647566
    Does any of you guys have 5 minutes to look at this problem?

    MickG im still counting on you :-)

    Joćo V.

+ Reply to Thread

Thread Information

Users Browsing this Thread

There are currently 1 users browsing this thread. (0 members and 1 guests)

Tags for this Thread

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