PDA

Click to See Complete Forum and Search --> : Preventing Duplicate entries


nmretd
Nov 8th, 1999, 10:10 PM
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 ???

Ghost
Nov 9th, 1999, 01:38 AM
You can check if the entry already exists in the table1. if not, then execute the insert statement.

Clunietp
Nov 9th, 1999, 10:26 AM
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

smalig
Nov 9th, 1999, 11:06 AM
You can make this field as indexed. Change value to OK (No Duplicates).

------------------
smalig
smalig@hotmail.com
smalig.tripod.com (http://smalig.tripod.com)