Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

vb and access

Options
  • 15-02-2005 9:58am
    #1
    Registered Users Posts: 483 ✭✭


    is there any way of checkin for duplicate records in vb when i try add another one?

    i need it: if a song already exists then msgbox else DBMusic.Recordset.Update
    but im not sure how to do it!
    any help will not go unnoticed!!
    Cheers


Comments

  • Registered Users Posts: 340 ✭✭Trizo


    You could have a select statement checking for the entry in the datatbase, if the number of rows returned = 0 then it is'nt a duplicate anything else means its already there.


  • Registered Users Posts: 1,184 ✭✭✭causal


    banbutcher wrote:
    is there any way of checkin for duplicate records in vb when i try add another one?

    i need it: if a song already exists then msgbox else DBMusic.Recordset.Update
    but im not sure how to do it!
    any help will not go unnoticed!!
    Cheers

    I'm a bit rusty at VB and Access, but:

    How are you specifying that a song already exists
    - is it based on the song 'name', or some code?

    Whatever it is - make that column unique within it's table, in your database definition.

    In your VB code - update the database with the song details - catch any error thrown (record already exists, whatever) by the database in your VB code and then open your message box if necessary.

    Basically - let the database handle checking whether the song is already there.

    causal


  • Registered Users Posts: 950 ✭✭✭jessy


    yep agree with Trizo, a simple SQL query will do it.


  • Registered Users Posts: 640 ✭✭✭Kernel32


    I agree with casual. Keep the data integrity rules in the database. Databases out live application front ends and having an index is the most efficent way of handling the problem.


Advertisement