CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 4 of 4
  1. #1
    Guest

    ADO Duplicate Key

    I am a novice using VB6....

    I have an ACCESS database setup and a form that updates the database. I am looking for soke example code that will help me trap a "duplicate key" error and format the error in a readable format (other than what is normally returned )...

    Thnak you in advance...


  2. #2
    Join Date
    Mar 2000
    Location
    Belgium
    Posts
    19

    Re: ADO Duplicate Key

    put this in the sub where the error occurs


    'put this at the top
    on error goto ADOerror
    'you can write here the rest of the code
    exit sub
    :ADOerror
    if err.number = 'put here the number that the error returns
    msgbox "Duplicate key in table" & vbcrlf & err.description, vbokonly, "error " & err.number
    end if





  3. #3
    Guest

    Re: ADO Duplicate Key

    I think this only works when you save your recordset, not with immediate effect
    as your control losts its focus.


  4. #4
    Join Date
    Jan 2000
    Location
    MO, USA
    Posts
    1,506

    Re: ADO Duplicate Key

    You can write a quick SQL Statement to test the value they enter though. do a select statement with the where clause value equal to the value the user entered. if you get something back, then it's a dupliate, if not, then it's okay.

    John

    John Pirkey
    MCSD
    www.ShallowWaterSystems.com
    John Pirkey
    MCSD (VB6)
    http://www.stlvbug.org

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured