Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations SkipVought on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using SubFrom Recordsetclone to delete records

Status
Not open for further replies.

jcw5107

Technical User
Jan 31, 2007
66
0
0
US
I have a form with a continuous subform. On the subform is a "checkbox" for each record. The checkbox is used to delete records from the subform. Also the checkbox is used to delete records from another table.
I am tryin' to figure out how to use the recordsetclone property of the subform to delete records from another table.
Below is what I am working with, and gettin' no-where fast..!!!
It checks to see if the PartMasterComments tbl has a matching WanNo via GBLWanNo (global variable), then if so delete the records from PartMasterComments that have a matching GBLWanNo, a matching IID in the subforms recordsetclone, and the checkbox is "true" in the subforms recordsetclone.
I sure hope this makes sense..!!
Any suggestions or other methods...???
Thanks for the help - in advance..!!!
jcw5107

If DCount("*", "PartMasterComments", "WanNo=" & GBLWanNo & "") > 0 Then
Dim rsTable As DAO.Recordset
Dim DeleteCt As Integer
Set rsTable = db.OpenRecordset("PartMasterComments")
Set rs = Me.PartsSubFrm.Form.RecordsetClone
DeleteCt = 0
rsTable.MoveFirst
Do While Not rsTable.EOF
If rsTable!WanNo = GBLWanNo And rsTable!IID = rs.Fields("IID") And rs.Fields("ForCoverSheet").Value = True Then
rsTable.Delete
DeleteCt = DeleteCt + 1
End If
rsTable.MoveNext
Loop
rsTable.Close
Set rs = Nothing
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top