Solved

Command Button-Change Name

Posted on 2014-03-18
9
699 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 34

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
 
LVL 7

Expert Comment

by:COACHMAN99
ID: 39937657
does the new sub command have the name of the button (as you wanted)?
0
Complete VMware vSphere® ESX(i) & Hyper-V Backup

Capture your entire system, including the host, with patented disk imaging integrated with VMware VADP / Microsoft VSS and RCT. RTOs is as low as 15 seconds with Acronis Active Restore™. You can enjoy unlimited P2V/V2V migrations from any source (even from a different hypervisor)

 

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 34

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

Do You Know the 4 Main Threat Actor Types?

Do you know the main threat actor types? Most attackers fall into one of four categories, each with their own favored tactics, techniques, and procedures.

Join & Write a Comment

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…
Today's users almost expect this to happen in all search boxes. After all, if their favourite search engine juggles with tens of thousand keywords while they type, and suggests matching phrases on the fly, why shouldn't they expect the same from you…
Basics of query design. Shows you how to construct a simple query by adding tables, perform joins, defining output columns, perform sorting, and apply criteria.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

743 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

Need Help in Real-Time?

Connect with top rated Experts

11 Experts available now in Live!

Get 1:1 Help Now