Want to win a PS4? Go Premium and enter to win our High-Tech Treats giveaway. Enter to Win

x
?
Solved

Command Button-Change Name

Posted on 2014-03-18
9
Medium Priority
?
1,105 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 39

Accepted Solution

by:
PatHartman earned 1500 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
Get free NFR key for Veeam Availability Suite 9.5

Veeam is happy to provide a free NFR license (1 year, 2 sockets) to all certified IT Pros. The license allows for the non-production use of Veeam Availability Suite v9.5 in your home lab, without any feature limitations. It works for both VMware and Hyper-V environments

 
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 39

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

Learn Veeam advantages over legacy backup

Every day, more and more legacy backup customers switch to Veeam. Technologies designed for the client-server era cannot restore any IT service running in the hybrid cloud within seconds. Learn top Veeam advantages over legacy backup and get Veeam for the price of your renewal

Question has a verified solution.

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

It’s the first day of March, the weather is starting to warm up and the excitement of the upcoming St. Patrick’s Day holiday can be felt throughout the world.
In Part II of this series, I will discuss how to identify all open instances of Excel and enumerate the workbooks, spreadsheets, and named ranges within each of those instances.
In Microsoft Access, learn the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…
Do you want to know how to make a graph with Microsoft Access? First, create a query with the data for the chart. Then make a blank form and add a chart control. This video also shows how to change what data is displayed on the graph as well as form…

618 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