There cannot be two like objects in the same mdb with the same name, so no
suppression of error messages or warnings is going to resolve this. There
are two ways to approach this.
One would be to use the DeleteObject method to delete the old table before
running the make table query to create a new one.
The other (the one I would use, I will explain why later) would be to delete
the data from the table and run an Append query rather than a Make Table
query to load the data. The reason is that a Make Table query uses the
default field length for text fields and guesses at what the data type should
be for numeric fields. This creates unneeded bloat, degrades performance,
and in rare cases can cause lose of decimals for numeric fields.
If I were doing it, I would open the table in design mode, set the field
properties approriately, and leave it in place. Then the sequence would be:
CurrentDb.Execute("DELETE * FROM mytable;"), dbFailOnError
CurrentDb.Execute("qappMyAppendQuery"), dbFailOnError
Annie said:
WOW!! You guys (or girls) are GREAT!! The last one did in fact get me through
what I needed. Only issue now, is that it's giving me an error (message)
that the table already exists for the Make Table query. I'm looking for
something (setting?) that allows this to be created without a warning.
thoughts?
:
Open the form with the button where you want to run the make table query in
design view.
Right click on the button and select Properties from the menu.
Select the Events tab of the properties dialog and select the Click event.
Since it is running a report, it will probably say [Event Procedure].
Once you have positioned your cursor in the Click Event text box, you will
see an icon on the right with 3 dots ...
Click on the dots and it will open the VB editor to that procedure.
If it is running a report, you will see a line that is will start with:
Docmd.OpenReport .......
Put the command to run the make table query just before that line:
CurrentDb.Execute("YourQueryNameGoesHere"), dbFailOnError
That's it!
:
I have an existing access db (MS Access 2000) which has a form with subforms
which are buttons.
Someone else designed this and I have NEVER really been in here before, but
I can write a mean query in Access. Right now, the form presents them with
buttons. They press them and it runs a report in preview mode. We want this
to stay the same, however, we need a make-table query to run before this
report.
How do I insert the command to run the make table query before the command
to run and preview the report?
I've made all the modifications and tested and I just need to automate the
make-table.