Results 1 to 2 of 2
  1. #1
    Join Date
    Jun 2003
    Location
    Singapore
    Posts
    20

    Question Unanswered: How to check if there is aleady a record??

    I wanna know the line of codes...

    I have a program that can be registered via handphone. But now the problem is, if the person's number is already in the database, I do want his/her record to be duplicated. Hmm, so may i know the line of codes please so that it won't be inserted again into the database if there is already his/her handphone number inside..

  2. #2
    Join Date
    Feb 2002
    Location
    San Francisco, CA
    Posts
    441
    I take the "handphone" means cellphone/mobile phone.

    You have two options;

    make the column which contains the cellphone number unique so the DBMS will not allow a duplicate record (hint: add a constraint),

    and or

    check before inserting the record into the table; e.g.
    Code:
    rs.source="select count(*) as x from x where cellnumber=" & cdbl(cellnumber)
    rs.open
    if rs.fields("x")>0 then
     'there is already a record, this would be a dupe
    else
     'insert the record it doesn't exist.
    end if
    rs.close
    set rs=nothing

Posting Permissions

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