vb and sql

  • Thread starter Thread starter cam_h
  • Start date Start date
C

cam_h

Guest
here's my situation:
I have a main form with a subform. The main form contains a field that determines the contents of the subform. The main form and subform both have seperate tables in which their data is stored.

I want to delete the contents of the subform's table if the user changes the contents of the control field on the main form.

I have currently have the code that will delete all relevant records from that subform table... but I don't want to delete anything if nothing exists. The code will currently delete "zero" rows.

I want to add an IF statement that runs a query to see if the subform's table contains any relevant records BEFORE proceeding with the delete.

The current query just says "delete * from (subform table) where (field1) = forms!field1.

Can anyone help with this, or offer a better solution?
 
try

if Me!subForm.Form.RecordCount > 0 then
run delete query
etc
end if
 

Users who are viewing this thread

Back
Top Bottom