On Mon, 2 Feb 2004 09:07:30 -0000, "Mark Reed" <ma*********@ntlworld.com>
wrote:
Hi All,
My database has a macro which opens up a table. A text file is then
pasted into the table and the then closed manually. Once closed, I then have
another macro which runs certain queries to append it to another table. Is
there a way to set a condition (as you can with a form) so that when the
table is closed, the macro runs?
I have no idea about VB so any suggestions with reference to VB will need to
be very specific!!!
Many thanks in advance,
Mark
Well, VB is not so hard, and macros are very limited. I think, if you take
the plunge, you'll find that VB is actually easier to write, read and
maintain, and far more flexible. I know you wanted specifics, but I don;t
have time to give them to you here. There are many great books on the
subject, and/or you can find good code examples on-line.
Next, in any Access application, you pretty much want to open forms, not
tables. You can have the form look just like the table by opening it in
Datasheet view. If you also open it in Dialog mode, the code that opened it
will wait until you close the form to continue on to the next statement,
but...
There are times when it is appropriate to open a form in Dialog mode, but in
most cases, it's better to have an action on the form itself initiate the next
action instead. This would even be true if you decide not to use VB for this
at all, but stick with macros.
So, create an unbound form (one with no Record Source), and create another
form bound to your table, and set its properties so it opens in Datasheet
view. Now, add the new form as a subform of the first (parent) form.
Finally, on the parent form, add a button that closes the form, and runs the
code or macro that performs the next step. This is event-driven vs linear
coding style, and it's how Access was designed to work.