Solved

Command Button-Change Name

Posted on 2014-03-18
9
934 Views
Last Modified: 2014-03-18
I have a form to which I am adding a command button.  I select cancel when the command button  wizard appears. I then go to the property sheet and click on the 3 dots next to on click and select code builder. It then opens the following:

Private Sub Command108_Click()

End Sub

How do I change the name Command108_Click() to DeleteTable1_Click(). I tried doing this by overriding the name Command108 with DeleteTable1 but when I press on the command it doesn't execute the code I entered.

conernesto
0
Comment
Question by:Conernesto
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 4
  • 3
  • 2
9 Comments
 
LVL 7

Expert Comment

by:COACHMAN99
ID: 39937508
rename the button to 'DeleteTable1' and start again (with 3 dots)
0
 

Author Comment

by:Conernesto
ID: 39937632
I am not being Successful. When I click on the 3 dots a new Sub Command opens.
0
 
LVL 37

Accepted Solution

by:
PatHartman earned 500 total points
ID: 39937640
If you change the name of the button after you've built the event procedures, the procedures with the original names become orphaned.  You can find them and rename them manually and then go back to the property sheet.  If you have renamed them to match the control's new name, they will reconnect when you click on the matching event builder.

To avoid problems (and ugly names), rename the control BEFORE you build any event procedures.  I suggest you do this even for controls where you don't expect to add event procedures.  It makes for a more professional form and will prevent future naming problems.  When you drag a control from the field list dialog, Access makes the control's Name property equal to the field name.  When you add a control from the toolbar, Access doesn't know what it will be bound to or if it will be bound and so can't assign a good name.
0
Use Case: Protecting a Hybrid Cloud Infrastructure

Microsoft Azure is rapidly becoming the norm in dynamic IT environments. This document describes the challenges that organizations face when protecting data in a hybrid cloud IT environment and presents a use case to demonstrate how Acronis Backup protects all data.

 
LVL 7

Expert Comment

by:COACHMAN99
ID: 39937657
does the new sub command have the name of the button (as you wanted)?
0
 

Author Comment

by:Conernesto
ID: 39937689
I am still a little bit lost.
0
 
LVL 7

Expert Comment

by:COACHMAN99
ID: 39937695
when you add a button is gets a default name
before you code you should rename it (so the automatically generated code sub uses the new name.
if you have old code that you wish to use, copy and paste to the new sub.

I am assuming when you now click 3 dots you see a new empty sub with the correct (button) name?
0
 

Author Comment

by:Conernesto
ID: 39937758
No. When drop the command button on my form, I click on Event procedure and the new empty sub is created. I then go to Alt F11 to find the empty sub and rename it. When I go back to the command button it is orphan again.
0
 
LVL 37

Expert Comment

by:PatHartman
ID: 39938104
If you read my reply again, it explains how to get them in sync again.  I'll do it step by step.
1. Change the Name property of the control to be the name you want.
2. Open the code module and find the orphaned code.  Replace the old control name with the new name.
3. Go back to the property sheet and click on the builder button again.  If the name of the control now matches the name of the procedure, you will see the code.  If you don't see your code, you can find it again, copy it and paste it here.  I would also delete the orphaned procedures to avoid future confusion.
0
 

Author Comment

by:Conernesto
ID: 39938117
I did not know how to change the command button name.  Now  I know. I went to the Property Sheet and selected the "All" tab. I then entered the name in the name row.

Thank you.
0

Featured Post

PeopleSoft Has Never Been Easier

PeopleSoft Adoption Made Smooth & Simple!

On-The-Job Training Is made Intuitive & Easy With WalkMe's On-Screen Guidance Tool.  Claim Your Free WalkMe Account Now

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

AutoNumbers should increment automatically, without duplicates.  But sometimes something goes wrong, and the next AutoNumber value is a duplicate.  This article shows how to recover from this problem.
Microsoft Access is a place to store data within tables and represent this stored data using multiple database objects such as in form of macros, forms, reports, etc. After a MS Access database is created there is need to improve the performance and…
Get people started with the utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Learn how to number pages in an Access report over each group. Activate two pass printing by referencing the pages property: Add code to the Page Footers OnFormat event to capture the pages as there occur for each group. Use the pages property to …

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question