DoCmd to delete records

  • Thread starter Thread starter davea
  • Start date Start date
D

davea

Hi

I have a command button that when clicked deletes certain records from
a subform based on an application number being equal. It deletes all
records with the same applciation number as currently shown on the
main form, see code below:

DoCmd.RunSQL ("DELETE FROM tblAdultDetails WHERE
[frmAdultDetails2].Form![ApplicationNum]=" +
Str(Me.ApplicationNumber))

However I would like it to only delete records if the fields
[MainApplicantFlag] =1 or [PartnerFlag] =1 as well as ApplicationNum
being equal. These are both number fields btw.

Can someone tell me what I should add to my code in order to do this?
I'm not sure of the syntax.

Thanks
 
Your question is pretty vague. Where are these fields? On the main form or
the subform? Are these conditions in addition to the one alreadty coded or
instead of? You need to be more specific.
The basic syntax for conditions in the WHERE clause is
condition1 AND condition2
condition3 OR condition4
You use parentheses to make things clear e.g.
(condition1 AND condition2) AND (condition3 OR condition4)

All of this is available in Access HELP

-Dorian
 
Answers in m.p.a.forms

Please do not post the same question repeatedly to different groups. If you
must, post to several groups at once, so that any discussion is not
fragmented.
 
Dave

Have you tried setting up a query to select the records that you want by
playing around with the criteria and then copying the SQL? You may have to
make one or two minor changes to get the syntax right (eg " to '), but I find
this quite a quick way of doing it.
 
Back
Top