Public Function DoCmd Runtime Error 2486

Joined
Apr 15, 2007
Messages
1
Reaction score
0
Hi All,

I am seeking to analyse and process a series of external MS Access databases.

As a first stage in this process I have written some VBA code as a standard function which undertakes the analysis and processing of each of these databases.

This module operates correctly when run in debug mode or from the MS Access visual basic tool bar within the database to be analysed.

However when I declare the function as a Public Function and call the module within the Criteria section of a query, as the penultimate stage in automatically manipulating a series of external databases, I experience some unexpected problems when the query is run.

I get a "Runtime Error 2486" message stating "You can't carry out this action at the present time. You tried to run a macro or used DoCmd object in visual basic to carry out an action. However MS Access is performing another activity that presents this action from being carried out now…"

The lines of code in which this error message is displayed relate to the following DoCmd methods DeleteObject, CopyObject, Rename, Close.

Apart from making the module a Public Function the code is identical in all respects to that which successfully runs in debug mode or from the MS Access visual basic tool bar.

Am I allowed to use DoCmd within a Public Function called through a query?

Any help will be gratefully appreciated,

Yours,


OliverA.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top