Solved

Command Button-Change Name

Posted on 2014-03-18
9
792 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
  • 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 35

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
Back Up Your Microsoft Windows Server®

Back up all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

 
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 35

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

Announcing the Most Valuable Experts of 2016

MVEs are more concerned with the satisfaction of those they help than with the considerable points they can earn. They are the types of people you feel privileged to call colleagues. Join us in honoring this amazing group of Experts.

Question has a verified solution.

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

The first two articles in this short series — Using a Criteria Form to Filter Records (http://www.experts-exchange.com/A_6069.html) and Building a Custom Filter (http://www.experts-exchange.com/A_6070.html) — discuss in some detail how a form can be…
When you are entering numbers in a speadsheet, and don't remember what 6×7 is, you just type “=6*7" instead. It works in every cell! This is not so in Access. To enter the elusive 42 in a text box, you have to find a calculator, and then copy the re…
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.

825 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