• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 395
  • Last Modified:

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?
0
G Scott
Asked:
G Scott
  • 5
  • 2
  • 2
  • +2
3 Solutions
 
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 MVPCommented:

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 MVPCommented:
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
Cloud Class® Course: Certified Penetration Testing

This CPTE Certified Penetration Testing Engineer course covers everything you need to know about becoming a Certified Penetration Testing Engineer. Career Path: Professional roles include Ethical Hackers, Security Consultants, System Administrators, and Chief Security Officers.

 
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 ArchitectCommented:
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 MVPCommented:
@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 MVPCommented:
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 ArchitectCommented:
"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 MVPCommented:
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
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: MCSA MCSE Windows Server 2012

This course teaches how to install and configure Windows Server 2012 R2.  It is the first step on your path to becoming a Microsoft Certified Solutions Expert (MCSE).

  • 5
  • 2
  • 2
  • +2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now