Hi all
I am trying to code a duplicate remover that allows the user to check that the two records really do refer to the same person before hitting the big red delete button.
I have this code:
dupeSurname is passed in from a combo box
The output of the debug lines is as follows:
But when I input that query into the query designer in access I get multiple results.
What am I doing wrong with the record set, or how do I get it to give me the correct number of records returned?
many thanks
mcalex
I am trying to code a duplicate remover that allows the user to check that the two records really do refer to the same person before hitting the big red delete button.
I have this code:
Code:
sql = "SELECT Caller.GivenNames, Organisation.OrgName, Caller.Phone " _
& "FROM Caller LEFT JOIN Organisation ON Caller.OrganisationID = Organisation.ID " _
& "WHERE Caller.Surname = """ & dupeSurname & """; "
Set dbase = CurrentDb
Set rst = dbase.OpenRecordset(sql)
rows = rst.GetRows
numReturned = UBound(rows, 2) + 1
Debug.Print "Dupe sql = " & sql
Debug.Print "Number of records: " & numReturned
The output of the debug lines is as follows:
Code:
Dupe sql = SELECT Caller.GivenNames, Organisation.OrgName, Caller.Phone FROM Caller LEFT JOIN Organisation ON Caller.OrganisationID = Organisation.ID WHERE Caller.Surname = "Mitchell";
Number of records: 1
What am I doing wrong with the record set, or how do I get it to give me the correct number of records returned?
many thanks
mcalex
Last edited: