delete records in subform if combo box changes

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.
 
D

deb

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top