Requery then Refresh my sub-form.
Posted on 1999-06-30
I have a subform whose source is a query. The source query has only one (1) table and it returns only those records from the table that are not 'marked_for_delete'. Obviously my table (the source for this query) has a field called marked_for_delete which is set to the current date when the user deletes a record via the subform.
My application does not allow the user to actually delete a record via the subfom, but instead it marks the record as deleted by setting the marked_for_delete field to the current_date.
In my ON_DEL;ETE event of my subform, I have written visual basic code to mark the deleted record as deleted (by setting the marked_for_delete field to the current date) and then cancel the ON_DELETE event (docmd.cancelevent).
A custom message pops up telling the user that the record was deleted.
I want to give the user the impression that he/she has indeed deleted the record (although in reality, it is only marked for delete). However, this is where my problem lies. How can I refresh my subform after the ON_DELETE event has completed, so that the subform no longer displays the 'deleted' record?
I tried ME.REFRESH in my code, but this didn't refresh the displayed records. The 'deleted' record was still displayed. I got an error when I attempted ME.REQUERY.
Can someone tell me how I can requery and then refresh my subform after a record is 'deleted', so that it excludes the record that was 'deleted' from its display.
Your help will be appreciated.