Control event code kept when renaming control.

Am I missing something? I vaguely remember Access being 'smart' and knowing that if you renamed your button the event code that goes along with that button would stay with them. Is there an option or something I don't have set or am I just remembering something that never existed in the first place? If it never did this then I better learn how to name my buttons better when I create them. I know it's no big deal to cut and paste the code in, but it should do this for you. In my opinion anyway. :)

Oh, and with that, as an example; I had a form with a few buttons on it. I then changed the design and wanted to add a tab control to separate the buttons. When I cut and pasted, all my events disappeared. The code was still there, but I had to reclick on the events to associate them again.

Is there a better way to do this?
LVL 1
G ScottAsked:
Who is Participating?

[Product update] Infrastructure Analysis Tool is now available with Business Accounts.Learn More

x
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

Scott McDaniel (Microsoft Access MVP - EE MVE )Infotrakker SoftwareCommented:
There is a NameAutocorrect feature, but it is buggy and nearly everyone suggests turning it OFF.

If you need to change your control names, use Rick Fisher's Find and Replace (www.rickworld.com). It is well worth the investment and will save you a lot of time.

However, copy/paste was your issue with the scenario you describe. I've never known Access to regenerate events AFTER pasting controls - it doesn't delete the original code, of course, so just setting the event to [Event Procedure] will "reactivate" the code, but Access won't do this for you.
0
Boyd (HiTechCoach) Trimmell, Microsoft Access MVPDesigner and DeveloperCommented:

Oh, and with that, as an example; I had a form with a few buttons on it. I then changed the design and wanted to add a tab control to separate the buttons. When I cut and pasted, all my events disappeared. The code was still there, but I had to reclick on the events to associate them again.

Is there a better way to do this?
AFAIK, Access has always done this.

With 2007/2010 you can use embedded macro that gets copied when you paste a command button.

If the event code not have a cancel parameter then I like to use a function call not an Event Procedure. This does copy when the command button is pasted.  This is great for code that is can be shared between forms. This helps to keep the form "lite weight".  Possibly  even the no code module behind the form which is even better.
0
Boyd (HiTechCoach) Trimmell, Microsoft Access MVPDesigner and DeveloperCommented:
Here is a better way. Use MZtools. It handles what you need.

MZTools (Freeware)

MZ-Tools is a  freeware add-in for  Visual Basic 6.0, Visual Basic 5.0 and the Visual Basic For Applications editor (provided by a VBA-enabled application such as those in Office 2000-2007) which adds several productivity features to the IDE.

Link:
http://www.hitechcoach.com/index.php?option=com_weblinks&view=weblink&id=70&catid=56&Itemid=20
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
Determine the Perfect Price for Your IT Services

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden with our free interactive tool and use it to determine the right price for your IT services. Download your free eBook now!

GRayLCommented:
TheHiTechCoach:  That's not really freeware - I see a free 30 day trial and then eighty dollars.  I'm not sure I like being routed first to your site before winding up at MZ-Tools.  Got a reason?
0
GRayLCommented:
jimpen:  tks, i appreciate the clari.  
0
DatabaseMX (Joe Anderson - Microsoft Access MVP)Database Architect / Systems AnalystCommented:
I want to reaffirm the Rick Fisher's Find & Replace has a very specific feature to in fact Rename Controls ... and will search the *entire* database, not just code ... with is what MZTools does - code only. F&R will find ALL occurrences of the Control name in queries (like Forms!YourFormName.YourControlName),  reports, macros .... etc.   On the other hand, MZTools's vba code searching feature is Stellar.  I use BOTH F&R and MZTools ... DAILY.

Rick just released F&R Version 9.00k for A2010 :
http://www.rickworld.com/download.html#FindAndReplace9   

"I've never known Access to regenerate events AFTER pasting controls" (et.al.)
It definitely never has ... but it definitely should :-)

Note that in MZTools ... there 'appears' to be a feature that does this, but that feature only works in the Visual Basic platform (eg VB6) ... *not* in Access VBA.

mx
0
Scott McDaniel (Microsoft Access MVP - EE MVE )Infotrakker SoftwareCommented:
<AFAIK, Access has always done this.>

I've never known Access to recreate your code and/or [Event Procedure] flags when copy/pasting controls. It doesn't remove the code, but neither does it reset the [Event Procedure] setting in the Event listing for the "new" control. Name Autocorrect might do this, but I've turned it off in every database I've worked with since that "feature" came out.
0
G ScottAuthor Commented:
Wow, there I go again recalling something that never even existed.

I guess I have to get better at naming things right out of the gate. This is why I have so many databases that have "Form1" in them. : \
0
Boyd (HiTechCoach) Trimmell, Microsoft Access MVPDesigner and DeveloperCommented:
@GRayL, MZYools is free for VBA and VB5/6.

From the MZTools web site:

"MZ-Tools 3.0 is a freeware add-in for Visual Basic 6.0, Visual Basic 5.0 and the Visual Basic For Applications editor (provided by a 32-bit VBA-enabled application such as those in Office 2000-2010) which adds several productivity features to the IDE."
0
Boyd (HiTechCoach) Trimmell, Microsoft Access MVPDesigner and DeveloperCommented:
jimpen,

The reason I use redirect links instead of the direct links is so that when the links changes I can update  the link so it still works.  My intent is to make sure the links I post will always work even if the target changes. For example,  when Microsoft updated their site I am able to ciorrect the link  if I use a redirect. When links don't work it makes both  the poster and  EE look unprofessional. Does EE monitor and repair broken links?   Can you recommend a better solution?

.

0
DatabaseMX (Joe Anderson - Microsoft Access MVP)Database Architect / Systems AnalystCommented:
"Does EE monitor and repair broken links?"
No.  
I think most users can figure out the new link, in the somewhat rare case when this happens.

mx
0
Boyd (HiTechCoach) Trimmell, Microsoft Access MVPDesigner and DeveloperCommented:
mx,

<<I think most users can figure out the new link>>
That has not been my experience since 1997.

<<in the somewhat rare case when this happens>>
It would be nice it was a rare occurrence. Unfortunately it happens to often. I have been dealing with problem links since 1997.  Microsoft's site has lots of broken internal link from all reorganizing they have done to own site over the years.  Another example: Albert (Access MVP ) recently moved his site to a new url. When testing my site's links I discovered it was broken,.  I searched for Albert's Word Merge code The first 30 links I found were all broken in a google search.  Over time a Google search might get better. At least I know the links I have posted still work if I use a redirect that I can maintain.
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.