Hi Dale3:
Thanks for your response.
The file I have have multiple records for the same company. What I am trying to do is to get the first record of a company to be the only one copied to the new DB.
Let me show how far I have gone and the problem I am still having. Let me know if I am on the right track and, if I am, what wrong with my code.
===================
Private Sub SearchForDups_Click()
'==========================================================
' This routine will browse the records of table tblCompanies and copy only the ones with unique company name to
' another table called tblCompanies_NEW
'========================================================== Dim MyRst1 As DAO.Recordset
Dim MyRst2 As DAO.Recordset
Dim stDocName, LastRecord As String
Dim NotDupsCtr As Long
Dim TotRecsCtr As Long
Set MyRst1 = CurrentDb.OpenRecordset("tblCompanies"

Set MyRst2 = CurrentDb.OpenRecordset("tblCompanies_NEW"

Dim fld As DAO.Field
Set fld = MyRst1("[Company]"
MyRst1.MoveLast
MyRst1.MoveFirst
MyRst1.MoveFirst ' Ensure pointer is at first record
LastRecord = fld
' Browse all records looking for duplicate company names
Do While Not MyRst1.EOF
If fld <> LastRecord Then
DoCmd.RunSQL "SELECT " & MyRst1 & " INTO " & MyRst2 & " FROM "" & MyRst2"
LastRecord = fld
NotDupsCtr = NotDupsCtr + 1
End If
TotRecsCtr = TotRecsCtr + 1
MyRst1.MoveNext
Loop
MsgBox "Total number of unique records: " & NotDupsCtr & " " & vbCrLf & _
"Total number of records source tblCompanies: " & TotRecsCtr
MyRst1.Close
MyRst2.Close
Set Rst1 = Nothing
Set Rst2 = Nothing
End Sub
=============
I am having problem in the line:
DoCmd.RunSQL "SELECT " & MyRst1 & " INTO " & MyRst2 & " FROM "" & MyRst2"
The word MyRst1 gets highlighed in yellow and this message comes up:
Compile Error
Type Mismatch.
Thanks again.