Many thanks for your reply. The addition of doevents seems to have solved my
problem
While I accept that sometimes I try things rather on the extreme ends, I
don't think that what I'm doing on this occasion is very strange.
What I'm trying to do is that, I have a template form that I use as the
skeleton of a number of forms, each of which is used in one part of the
program that I use to process orders.
For example, when the user wants to import some incoming orders to the
database, the skeleton form is copied under appropriate name, the option
group is filled with option buttons, with the label of each showing the name
of the order file itself (an excel file, stored in a predetermined
directory). The user selects one of the option buttons, and the
corresponding file is imported and processed. Once imported, the original
order file will be erased from that directory and the output of the process
will be placed in a different directory, to be the input of another process,
whenever the user selects the routine to process it. Due to the fact that
the number of files in that directory is not known, and will always be
different, I had to create the controls on the fly.
As if this is not enough, I delete the form after any file is processed, and
rebuild it from scratch to reflect the new structure of the directory, with
the processed file deleted.
If I just close the form and check for its existence whenever I need to use
the routine again, I don't have any problems to delete it, presumably
because the db engine has had the time needed to close it properly.
It could be said that I did not have to close it. Indeed, it was my first
choice just to delete the option buttons and recreate them as needed, and I
had built it this way. After some time, and just by chance, I read about the
"lifetime number of controls" that can be created on a form, which is
something like 745. Therefore, I had to rewrite a lot of things to avoid
getting a "too many controls" error message every couple of months.
Now, thanks to you, I think I'm going to have a working scheme.