macro doesn't execute delete queries

G

Guest

Hi
I have a macro in the OnClose event on a main form. The macro only contains 2 delete queries to delete records from two different tables , the main form and the subform. Each of the tables / forms contain a yes/no checkbox. When the user checks yes on the main form to delete this record, I have used setvalue to also turn the value to yes on the subform. The Macro OnClose contains the queries to delete any records that equal yes on either table. They delete the records in the main table, but not the subform/table unless I open and close the main form again or exit the database and reopen
I have tried putting the macro in After Update, On Deactivate, spliting the maco into seperate actions and the result is always the same. The reocrd is removed from the main table, but not the sub"table". Referential cascading deletes are not an option here. Would take to many paragraphs to explain. Why won't the query fire OnClose for the subtable/subform
Would really appreciate some input.
 
S

Steve Schapel

Dawn,

The reason for this is that the value of the Yes/No field in the second
table is not being updated, i.e. the change to the record is not being
saved. This is expected in the case of using SetValue, which is
changing the value of the form control, but this does not get
transferred to the table, as usual, until you close the form or move to
another record. One solution would be to use an Update Query (and run
this from the macro with an OpenQuery action) instead of SetValue in
order to tick the checkboxes. This would be a preferable approach in
any case. Another idea may be to use a RunCommand,SaveRecord action
after the SetValue.
 

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