|
Question : Delete All Records from Recordset
|
|
MS Access 2000 I am trying to delete all the records from a recordset.
I've tried scrolling through using ADO and deleting each record individually... here's the code: ***** strKeyQry = "SELECT tblMaster.ContactID, tblTemp.ContactID, tblMASTER.Flag, tblMASTER.[Email] " & _ "FROM tblMASTER INNER JOIN tblTemp ON (tblMASTER.[Email] = tblTemp.[Email]);"
Set rstKey = New ADODB.Recordset rstKey.Open strKeyQry, CurrentProject.Connection, _ adOpenStatic, adLockOptimistic
Do Until rstKey.EOF rstKey.Delete rstKey.MoveNext Loop rstKey.Update ***** The above code generates an error on rstKey.Update, because it is at EOF, and all the records have been deleted.
I've also tried it using SQL *** DoCmd.RunSQL ("DELETE tblMaster.ContactID, tblTemp.ContactID, tblMASTER.Flag, tblMASTER.[Email] " & _ "FROM tblMASTER INNER JOIN tblTemp ON (tblMASTER.[Email] = tblTemp.[Email]);" *** and I come up with the error: "Specify the table containing the records you want to delete"
Any help would be greatly appreciated!
Thanks! cdmac
|
|
Answer : Delete All Records from Recordset
|
|
How about:
DELETE * FROM tblMASTER Where Email In (Select Email From tblTemp)
then
Delete * From tblTemp
Michael
|
|
|
|