delete records in subform if combo box changes

  • Thread starter Thread starter deb
  • Start date Start date
D

deb

I have a form called f4Project. It has a subform called f4ProjUnitSub
(continuous subform).

If the combobox called SiteID, in the f4Project form is changed. I would
like all records in the subform field called UnitID, that correspond with the
main forms SiteID to be deleted.

SiteID is a secondary key so it will not cascade delete.

This way the user will need to choose the UnitID that belongs to the new
SiteID.
 
found the information... see below

Dim cmd As ADODB.Command
Dim strSQL As String

Set cmd = New ADODB.Command
cmd.ActiveConnection = CurrentProject.Connection
cmd.CommandType = adCmdText

strSQL = "DELETE * FROM t032ProjUnit " & _
"WHERE ProjectID = " & Me.ProjectID

cmd.CommandText = strSQL
cmd.Execute

Me.f4ProjUnitSub.Requery
 
Back
Top