Validate Duplicates when importing excel (1 Viewer)

Hansi

New member
Local time
Today, 11:35
Joined
Jun 4, 2018
Messages
8
Hi,
I have code written which imports excel data to a access table and I want to validate it to prevent importing the duplicates. How can I do that?

Thanks.


My code is below,
Code:
Public Function FolderSelection() As String
    Dim objFD As Object
    Dim strOut As String
    
    strOut = vbNullString
    Set objFD = Application.FileDialog(3)
    If objFD.Show = -1 Then
        strOut = objFD.SelectedItems(1)
    End If
    Set objFD = Nothing
    FolderSelection = strOut
    strChoice = FolderSelection
    If Len(strChoice) > 0 Then
    Me.test = strChoice
    DoCmd.TransferSpreadsheet _
                    TransferType:=acImport, _
                    SpreadsheetType:=acSpreadsheetTypeExcel9, _
                    TableName:="All_Detail", _
                    FileName:=strChoice, _
                    HasFieldNames:=True
    Else
    Me.test = " "
    End If
End Function
 

JHB

Have been here a while
Local time
Today, 06:35
Joined
Jun 17, 2012
Messages
7,732
Import your data into a temporary table, then run an unmatched query.
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 12:35
Joined
May 7, 2009
Messages
19,226
you can also index (on fields you dont want dups). Us no duplicate.
 

Users who are viewing this thread

Top Bottom