Hi,
So long as you have a Reference to the DAO Object Library you can do the following:
Dim dbs as DAO.Database, rstMain as DAO.RecordSet, rstLookUp as DAO.Recordset
Dim sql as String
Set dbs = CurrentDB
sql = "Select * From "
Set rstMain = dbs.OpenRecordset(sql)
sql = "Select * From "
Set rstLookUp = dbs.OpenRecordset(sql)
If rstMain.RecordCount = 0 Then
Exit Sub 'Empty Table - Quit
Else
rstMain.MoveFirst
End If
if rstLookUp.RecordCount = 0 Then
Exit Sub
Else
rstLookUp.MoveFirst
End If
Do While Not rstMain.EOF
Do While Not rstLookUp.EOF
if rstLookUp! = rstMain! Then
MsgBox "Oops " & rstMain!! & " has been duplicated."
end if
rstLookUp.MoveNext
Loop
rstMain.MoveNext
Loop
'Clean Up:
Set rstLookUp = Nothing
Set rstMain = Nothing
Set dbs = Nothing
Chris147
Junior Poster in Training
58 posts since Jun 2007
Reputation Points: 10
Solved Threads: 4
Hmn...
About all I can see wrong is (assusming you have pasted your code from Access VBA) you have a typo in the 'Set' event for rstMain (should be: "Set rstMain = dbs.OpenRecordset(sql)" - not "...dset(sql1)".
You also don't need the brakets around around the table names in the If.. ..Then statement - you only need brackets when you have spaces in your table names and that's bad practice.
If none of these fix the problem double check the table names and field names - the error you have is Access looking for, and not finding, one of the above.
HTH,
Chris.
Chris147
Junior Poster in Training
58 posts since Jun 2007
Reputation Points: 10
Solved Threads: 4
Are you sure they are in the right order?
According to your last post PRIMARYSSN a Field in OtherAdults and SSN is a Field in FormInformation.
If there are no spaces in the Field Names (and there clearly isn't here) get rid of the brackets.
If no joy post here or send a personal message and I'll pick it up.
HTH,
Chris.
Chris147
Junior Poster in Training
58 posts since Jun 2007
Reputation Points: 10
Solved Threads: 4