Hi,
I have a VBA-program in Access. Purpose of this program is to calculate statistics from individual data stored in Access tables.
Because of the large amount of data and data-manipulations, I need to compact the database very frequently. I would like to automate this.
My program works as follow:
It's bizarre that it does the compact the first time, but any other time, it gives errors.
Does anyone know any alternatives so I really can do multiple compactings?
I was thinking of using a second database which does the compacting, something like that: (all automatically)
1) calculate year X in original mdb
2) switch to db2.mdb which controls the compacting of original.mdb
3) switch to original mdb which continues calculating year Y
4) switch to db2.mdb which controls the compacting of original.mdb
5) switch to original mdb which continues calculating year Z
etc...
Is this possible in an automatic way?
Is there anybody who can help me?
Thanks in advance.
Frederik
I have a VBA-program in Access. Purpose of this program is to calculate statistics from individual data stored in Access tables.
Because of the large amount of data and data-manipulations, I need to compact the database very frequently. I would like to automate this.
My program works as follow:
Private sub startbutton()
Call function1
Call function2
Etc…
'Compact database -> all calculations are being done for year X, I need to 'compact to continue with the next year Y
CommandBars("Menu Bar").Controls("Tools").Controls("Database utilities").Controls("compact and repair database...").accDoDefaultAction
End sub
So far, anything works good. After the first compact, the mdb-file with the form restarts automatically. It should now automatically calculate statistics for year Y. So I repeat the same procedure as with the start button, but now under a load_form event:Call function1
Call function2
Etc…
'Compact database -> all calculations are being done for year X, I need to 'compact to continue with the next year Y
CommandBars("Menu Bar").Controls("Tools").Controls("Database utilities").Controls("compact and repair database...").accDoDefaultAction
End sub
Private sub load_form
Call function1
Call function2
Etc…
And now, here comes the problem:Call function1
Call function2
Etc…
CommandBars("Menu Bar").Controls("Tools").Controls("Database utilities").Controls("compact and repair database...").accDoDefaultAction
ð error message: Method ‘accDoDefaultAction of object _CommandBarButton failed.
It's bizarre that it does the compact the first time, but any other time, it gives errors.
Does anyone know any alternatives so I really can do multiple compactings?
I was thinking of using a second database which does the compacting, something like that: (all automatically)
1) calculate year X in original mdb
2) switch to db2.mdb which controls the compacting of original.mdb
3) switch to original mdb which continues calculating year Y
4) switch to db2.mdb which controls the compacting of original.mdb
5) switch to original mdb which continues calculating year Z
etc...
Is this possible in an automatic way?
Is there anybody who can help me?
Thanks in advance.
Frederik