run-time error 29068 by deleting modules

C

Cesar Romani

I'm trying to delete all class modules whose name begin with "struct".
If I use the following subroutine, it deletes only one module and spits the
run-time error 29068: "cannot complete this operation. You must stop the
code and try
again"
Where is the error here?
---------------------
Sub deleteModules()
Dim i As Integer

For i = CurrentProject.AllModules.Count - 1 To 0 Step -1
If Left(CurrentProject.AllModules(i).Name, 6) = "struct" Then
DoCmd.DeleteObject acModule, CurrentProject.AllModules(i).Name
End If
Next i
End Sub
 
M

Maurice

Could it be that the code you are running is referring to a "struct"-module
or is the actual code in a "struct"-module?

Maurice
 
G

Guest

I haven't tried it :~)

But I will be surprised if you are able to delete modules in the
current project.

Deleting a module puts the project in a de-compiled state. The
code can't run when the project is in a de-compiled state: it needs
to re-compile. The project can't re-compile while you are running
code: you need to stop the code and try again.

Try changing the VBA properties so that it does not automatically
compile (this is opposite to the usual recommendation).

Try using a separate Access.Application object, so that you can
run the code in one Application object, to delete the modules in
a different Application object.

(david)
 
B

Bas

Hi, I ran into the exact same issue when deleting a Report:
DoCmd.DeleteObject acReport, strReportName
It actually does delete the report but then still gives the error message.

It turned out the issue was caused by the fact that the database was located on a network drive. After I copied the *.mdb file to my hard-drive and ran the code again the error message no longer appeared.

EggHeadCafe.com - .NET Developer Portal of Choice
http://www.eggheadcafe.com
 
Y

Yvonne Anderson

What it is this group, and why is it appearing on my computer?

Yvonne Michele Anderson
(e-mail address removed)
 

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