Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Forms Programming / June 2006

Tip: Looking for answers? Try searching our database.

Problem naming controls

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
atlinc@hotmail.com - 18 Jun 2006 04:04 GMT
I built a simple form in Access 2K. It has a textbox, listbox and two
command buttons. I went to the properties window/other tab and named my
controls. I opened the Visual Basic editor and went to the drop down
list of controls and all of the controls were still named with the name
Access gave them when they were created. For example the first command
button I created was given the name Command4 and I named it cmdAdd but
in the VBE dropdown list it is still named Command4. This has happened
to me before and I believe I got it to recognize my names by going to
Debug/Compile, but it isn't working this time.

Can anyone tell me why this sometimes happens and sometimes not when I
create a form? And what can I do to get the VBE to recognize the names
I have assigned? BTW the control names I assigned are not the same as
the names of any fields in the database, nor are they reserved words.
Allen Browne - 18 Jun 2006 04:38 GMT
You are correct: when you rename a control, any code that was associated
with it becomes disassociated, and retains the old name.

The solution is to search'n'replace in the code window to change all
occurrences of that name in that module. (On the Edit menu.)

In general, you want to change the name of the control before you assign any
event procedures to it.

There are some contexts where Access attempts to still recognise a field
where you change its name, but it does not even attempt to do that in the
VBA code window. In any case, the implementation of this is so flawed that
it is much more likely to corrupt your database than much else. More
details:
   Failures caused by Name Auto-Correct
at:
   http://allenbrowne.com/bug-03.html

It sounds like you are probably aware of the problems that can result from
using reserved words as control names. If you are interested, tblBadWord
contains a list of those names to avoid in this utility database:
   http://allenbrowne.com/AppIssueChecker.html

And just BTW, personally I don't bother changing the name of every control
so it is different from the name of the field it is bound to. My style is to
use the prefixes on unbound controls and controls bound to expressions only.

Signature

Allen Browne - Microsoft MVP.  Perth, Western Australia.
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

>I built a simple form in Access 2K. It has a textbox, listbox and two
> command buttons. I went to the properties window/other tab and named my
[quoted text clipped - 10 lines]
> I have assigned? BTW the control names I assigned are not the same as
> the names of any fields in the database, nor are they reserved words.
JethroUK© - 18 Jun 2006 09:48 GMT
and hence the birth of naming convention:

http://support.microsoft.com/kb/q110264/

> You are correct: when you rename a control, any code that was associated
> with it becomes disassociated, and retains the old name.
[quoted text clipped - 42 lines]
> > I have assigned? BTW the control names I assigned are not the same as
> > the names of any fields in the database, nor are they reserved words.
Rod Plastow - 18 Jun 2006 12:50 GMT
Hi,

I think no one has yet addressed your very first problem.  After you have
typed a new control name in the properties box make sure you type a [TAB] or
[ENTER] to force an update before navigating to the next control.  There are
situations where the UI fails to overwrite the control name.

Rod

> I built a simple form in Access 2K. It has a textbox, listbox and two
> command buttons. I went to the properties window/other tab and named my
[quoted text clipped - 10 lines]
> I have assigned? BTW the control names I assigned are not the same as
> the names of any fields in the database, nor are they reserved words.
atlinc@hotmail.com - 18 Jun 2006 13:48 GMT
Thanks Rod, that was the problem. I would click on a control to select
it, go to the properties box and name it, click on the next control and
so on. This would change the name in the Access environment but not the
VB environment. Isn't that strange? Anyway, hitting [ENTER] before
moving on takes care of the problem. Thanks again for the help!

> Hi,
>
[quoted text clipped - 19 lines]
> > I have assigned? BTW the control names I assigned are not the same as
> > the names of any fields in the database, nor are they reserved words.
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.