?
Solved

Command Button-Change Name

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

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 your Conversational Ransomware Defense e‑book

This e-book gives you an insight into the ransomware threat and reviews the fundamentals of top-notch ransomware preparedness and recovery. To help you protect yourself and your organization. The initial infection may be inevitable, so the best protection is to be fully prepared.

 
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 40

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

Become an Android App Developer

Ready to kick start your career in 2018? Learn how to build an Android app in January’s Course of the Month and open the door to new opportunities.

Question has a verified solution.

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

This article shows how to get a list of available printers for display in a drop-down list, and then to use the selected printer to print an Access report or a Word document filled with Access data, using different syntax as needed for working with …
Sometimes MS breaks things just for fun... In Access 2003, only the maximum allowable SQL string length could cause problems as you built a recordset. Now, when using string data in a WHERE clause, the 'identifier' maximum is 128 characters. So, …
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…
How can you see what you are working on when you want to see it while you to save a copy? Add a "Save As" icon to the Quick Access Toolbar, or QAT. That way, when you save a copy of a query, form, report, or other object you are modifying, you…
Suggested Courses

579 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