Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Queries / April 2006

Tip: Looking for answers? Try searching our database.

how to not insert duplicates

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
ricknicholson@att.net - 07 Apr 2006 20:20 GMT
I have an Insert sql statement but am strugling with how not to have it
insert any duplicates LOTNUM_72 if already exists.  Any help is
appreciated.

sSQL = "INSERT INTO [LotTrackingHistory] (LOTNUM_72, TNXDTE_72,
PRTNUM_72, USRNAM_72," & _
                                                           "STKID_72,
TNXQTY_72, ORDNUM_72, UDFREF_72)" & _
                   " Values " & _
                   "('" & rowX.Item("LOTNUM_72").ToString & "'," & _
                   "#" & rowX.Item("TNXDTE_72") & "#," & _
                   "'" & rowX.Item("PRTNUM_72").ToString & "'," & _
                   "'" & rowX.Item("USRNAM_72").ToString & "'," & _
                   "'" & rowX.Item("STKID_72").ToString & "'," & _
                   "'" & rowX.Item("TNXQTY_72").ToString & "'," & _
                   "'" & rowX.Item("ORDNUM_72").ToString & "'," & _
                   "'" & rowX.Item("UDFREF_72").ToString & "')"
John Vinson - 08 Apr 2006 01:05 GMT
>I have an Insert sql statement but am strugling with how not to have it
>insert any duplicates LOTNUM_72 if already exists.  Any help is
>appreciated.

You can use a unique Index on LOTNUM_72, if that makes sense for the
rest of the application. You'll need to supress the warning messages
(by using the querydef Execute method and trapping and ignoring the
error, preferably).

What is RowX? Could it be defined in such a way that existing values
of LOTNUM_72 aren't available? Or could you use the BeforeUpdate event
of the control containing LOTNUM_72 to look up the value entered in
the table, and cancel if it's there?

                 John W. Vinson[MVP]    
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.