Results 1 to 4 of 4

Thread: Preventing Duplicate entries

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Sep 1999
    Location
    London, England
    Posts
    213

    Post

    I am using the following code to update records in an Access 97 Database:

    Dim oWs As Workspace
    Dim oDb As Database
    Dim strSQL as string

    UserID = List1.Text

    Set oWs = Workspaces(0)
    Set oDb = OpenDatabase("c:\temp\DB1.mdb")

    strSQL = " INSERT INTO Table1 " _
    & "(Field1) VALUES " _
    & "('" & UserID & "');"

    List2.AddItem List1.Text

    oDb.Execute strSQL
    oDb.Close

    This works fine BUT, how can I do a check on Field1 in Table1 to make sure that a duplicate entry is not made ???

  2. #2
    Junior Member
    Join Date
    Oct 1999
    Posts
    31

    Post

    You can check if the entry already exists in the table1. if not, then execute the insert statement.

  3. #3
    Guru Clunietp's Avatar
    Join Date
    Oct 1999
    Location
    USA
    Posts
    1,844

    Post

    make it indexed with no duplicates to let Access do the backend work -- it is better that you do not have to issue 2 SQL statements against your database

  4. #4
    Addicted Member
    Join Date
    Oct 1999
    Posts
    232

    Post

    You can make this field as indexed. Change value to OK (No Duplicates).

    ------------------
    smalig
    [email protected]
    smalig.tripod.com

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