+ Reply to Thread
Results 1 to 8 of 8

ADODB Record Upate

  1. #1
    Registered User
    Join Date
    09-05-2012
    Location
    Dallas, TX
    MS-Off Ver
    Excel 2010
    Posts
    9

    ADODB Record Upate

    Hello,

    I am using ADODB to create new record in an access db. Now, that I'm past that hurdle, how do I check if the unique key already exists and then update that record? Any help would be greatly appreciated.

    Please Login or Register  to view this content.

  2. #2
    Forum Expert mike7952's Avatar
    Join Date
    12-17-2011
    Location
    Florida
    MS-Off Ver
    Excel 2007, Excel 2016
    Posts
    3,519

    Re: ADODB Record Upate

    Something like this

    Please Login or Register  to view this content.
    Thanks,
    Mike

    If you are satisfied with the solution(s) provided, please mark your thread as Solved.
    Select Thread Tools-> Mark thread as Solved.

  3. #3
    Registered User
    Join Date
    09-05-2012
    Location
    Dallas, TX
    MS-Off Ver
    Excel 2010
    Posts
    9

    Re: ADODB Record Upate

    Mike,

    Thank you. Exactly what I was trying to do.

  4. #4
    Forum Expert mike7952's Avatar
    Join Date
    12-17-2011
    Location
    Florida
    MS-Off Ver
    Excel 2007, Excel 2016
    Posts
    3,519
    Your welcome

  5. #5
    Registered User
    Join Date
    09-05-2012
    Location
    Dallas, TX
    MS-Off Ver
    Excel 2010
    Posts
    9

    Re: ADODB Record Upate

    Mike,

    I finally have played with the code a little. I get a Run-time error 3219. If I add .Update before the 'end if' it throws a Run-time error -214217887 (80040e21) - "The changes you requested to the table were not successful because they would create duplicate values in the index, primary key, or relationship. Change the data in the field or fields that contain duplicate data, remove the index or redefine the index to permit duplicate entries and try again." Where am I going wrong? Here is my code below:

    Please Login or Register  to view this content.

  6. #6
    Forum Expert mike7952's Avatar
    Join Date
    12-17-2011
    Location
    Florida
    MS-Off Ver
    Excel 2007, Excel 2016
    Posts
    3,519

    Re: ADODB Record Upate

    Try this


    Please Login or Register  to view this content.

  7. #7
    Registered User
    Join Date
    09-05-2012
    Location
    Dallas, TX
    MS-Off Ver
    Excel 2010
    Posts
    9

    Re: ADODB Record Upate

    Mike,

    I made a mistake. I've tried your method in your last reply. If I add .Update before the 'end if' it throws a Run-time error -214217887 (80040e21) - "The changes you requested to the table were not successful because they would create duplicate values in the index, primary key, or relationship. Change the data in the field or fields that contain duplicate data, remove the index or redefine the index to permit duplicate entries and try again."

  8. #8
    Registered User
    Join Date
    09-05-2012
    Location
    Dallas, TX
    MS-Off Ver
    Excel 2010
    Posts
    9

    Re: ADODB Record Upate

    Mike,

    I've had some time to play with the code. For some reason the EOF if statement is skipped even if the record exists. Any ideas?

+ 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