How to get rid of code in class module?

spikepl

Eledittingent Beliped
Local time
Today, 18:19
Joined
Nov 3, 2010
Messages
6,134
I have a call module for my form. There there is a piece of code I cannot get rid of:


Code:
Private Sub Box262_Click()

End Sub

I delete it, save the form, close (Access 2007), open, and there it is again.

I have imported all bits and pieces into a new DB, but it it is still there.

How to kill such fluff??
 
Delete all the Event properties from the control in the form design.

BTW You can get rid of absolutely everying including the module itself by changing the HasModule property of the form to No.
 
Plus after deleting the code, Compile it in the code window (i.e. DEBUG menu > hit COMPILE).

Then also perform a Compact & Repair after all of that.

NB: Just as a side note, deleting the [Event Procedure] from the controls events doesn't really get rid of the code. Just disallows the code from running.
 
The control is a Rectangle - I needed a graphic rectangle on my form so I grabbed Rectangle. It does not care how much I delete the code, or wipe the Rectangle's event list - next time it is still there in the class thinggy.
 
Did you follow the steps as explained in my last two posts?

And if you use Galaxiom's method of setting the HasModule, you can simply copy the whole code, paste it into Notepad and remove the problem code, set the HasModule property to No and paste the code back in.
 
Some kind of freaky corruption. If vbaInet's solution doesn't work I would try exporting the form to another database, delete the original and import it back in.
 
#3 & #4 Tried this right now - the persistent SOB is back :-(

#7 I just imported the entire enterprise into a new virgin DB - still cannot get rid of that code.

Maybe I just drop the Rectangle-control, draw four lines instead and blame this problem on the mysterious ways of God (oops, Gates) :-)
 
Select all the controls on the form and copy to the clipboard. Then create a new empty form and paste them in.

Copy the VBA text to the clipboard. Set an event on one of the controls to create a form module. Select the resulting code and paste the original code over it. Go back to the form designer and relink the control's events to the pasted code.

Must be some way to get rid of the pesky WreckedAngle.

Maybe decompile the database.
Use this commandline like this

AccessProgramPath\msaccess.exe /decompile annoyingdatabasename
 
#9 Thank you.. I just need to strip som stuff (to keep my customer happy). BRB
 
OK here goes:

The form's name is Form1. The offending control is in the Tab "Analyse" - the rectangle you should see there. I have stripped out data and the analysis part, so not all the buttons lead to anything.
 
Last edited:
That is a seriously bad piece of code. My browser refuses to even download the zip file. :confused:

Bizarre. I can edit this post but I can't close the tab. Are there 666 controls on the form? :rolleyes:

I closed all the other tabs and now I cannot close the browser (IE8)window. :eek:
 
Last edited:
It's hard to spot the rectangle in the midst of your many controls. What is it called?

The tab is even behaving oddly in design view so I would think it's a corruption issue (as Galaxiom mentioned).
 
Actually I was able to get it from your code. Following the steps I mentioned, it got removed. Do you want the db back?
 
#14 I had some problems wit the TAB control before - the corresponding module was full of things like Private Sub pppppppppppppppppppppppppppp etc... so perhaps the TAB-control is rotten in general? The Rectangle is Box 262

#13 I think my programming skills do not extend to corrupting your ZIP-download:-)
 
#15 Thank you - of course I'd like it back! I wonder what I did wrong, because I followed your recipe...
 
#13 The update...

666 the mark of the devil ? I doubt seriously that I have 666 controls :-)
 
GalaxiomAtHome I think the OP is using 2007. You use the older versions right?

spikepl - I've attached it. My advice would be to recreate the whole form, copy and paste the code back into each form module and reattach the relevant [Event Procedures]. Access doesn't reattach the procedures for you.

In creating a new form, do not copy the tab control, drop a new one onto the new form and you can copy and paste the other controls onto the relevant tabs.
 
Last edited:
#19 Will do, thank you.

I used to work in 2003, hence the TAB-control. First midway I realised I could have just as well used the new TAB-layout of the view of the various forms, but was too far into the programming to bother to go back.

But, considering the pain the TAB-control has given me, I do not plan on using it again, unless unavoidable.
 

Users who are viewing this thread

Back
Top Bottom