I am trying to delete a record and all of its children recursively, but I had no success so far. Below is what I tried.
Thanks for the help.
SWK
Public Sub DeleteJobGroupHeader(JobGroupHeaderID As Integer)
Set cn = CurrentProject.Connection
'Find all the children
SQLstring = _
"Select JobGroupHeaderID from JobGroupHeader Where JobGroupHeaderParentID =" & JobGroupHeaderID
Set rst = cn.Execute(SQLstring)
Do While Not rst.EOF 'if it has children find them
DeleteJobGroupHeader rst!JobGroupHeaderID
rst.MoveNext
Loop
'if it doesn't have children delet it
SQLstring = _
"Delete From JobGroupHeader Where JobGroupHeaderID=" & JobGroupHeaderID
cn.Execute (SQLstring)
End Sub
Thanks for the help.
SWK
Public Sub DeleteJobGroupHeader(JobGroupHeaderID As Integer)
Set cn = CurrentProject.Connection
'Find all the children
SQLstring = _
"Select JobGroupHeaderID from JobGroupHeader Where JobGroupHeaderParentID =" & JobGroupHeaderID
Set rst = cn.Execute(SQLstring)
Do While Not rst.EOF 'if it has children find them
DeleteJobGroupHeader rst!JobGroupHeaderID
rst.MoveNext
Loop
'if it doesn't have children delet it
SQLstring = _
"Delete From JobGroupHeader Where JobGroupHeaderID=" & JobGroupHeaderID
cn.Execute (SQLstring)
End Sub