Hello.
I have a form that shows company info. If user deletes a company I want the entries in a table in another acess DB to be deleted as well for RI.
I'm having trouble finding the best place to put my code. If I put in in afterdelconfirm the me.company_numeric used is not the company that was deleted it is the company that pops up on screen to to replace the deleted one.
If it is best to put it in the beforedelconfirm I'm not sure of the best way to have it there, with cancelling deletions etc.
This is my code I'm trying to find a place for:
'deletes entry from plan-comp table to maintain integrity
Dim deltcomplan As Database
Dim deltcomplanrec As DAO.Recordset
Dim delcompnum As Long
Set deltcomplan = CurrentDb
Set deltcomplanrec = deltcomplan.OpenRecordset("plan-company t",dbopendynaset)
delcompnum = Me.Company_Numeric
deltcomplanrec.MoveFirst
Do While Not deltcomplanrec.EOF
If deltcomplanrec![Company Numeric] = delcompnum Then
deltcomplanrec.Delete
End If
deltcomplanrec.MoveNext
Loop
Set deltcomplanrec = Nothing
Set deltcomplan = Nothing
thanks in advance
I have a form that shows company info. If user deletes a company I want the entries in a table in another acess DB to be deleted as well for RI.
I'm having trouble finding the best place to put my code. If I put in in afterdelconfirm the me.company_numeric used is not the company that was deleted it is the company that pops up on screen to to replace the deleted one.
If it is best to put it in the beforedelconfirm I'm not sure of the best way to have it there, with cancelling deletions etc.
This is my code I'm trying to find a place for:
'deletes entry from plan-comp table to maintain integrity
Dim deltcomplan As Database
Dim deltcomplanrec As DAO.Recordset
Dim delcompnum As Long
Set deltcomplan = CurrentDb
Set deltcomplanrec = deltcomplan.OpenRecordset("plan-company t",dbopendynaset)
delcompnum = Me.Company_Numeric
deltcomplanrec.MoveFirst
Do While Not deltcomplanrec.EOF
If deltcomplanrec![Company Numeric] = delcompnum Then
deltcomplanrec.Delete
End If
deltcomplanrec.MoveNext
Loop
Set deltcomplanrec = Nothing
Set deltcomplan = Nothing
thanks in advance