How to loop through numerous command buttons to change caption name

chrisjames25

Registered User.
Local time
Today, 08:48
Joined
Dec 1, 2014
Messages
404
Hi

I have a form with around 200 command buttons on it. To the right of each command button is a textbox.

Idea is using double click event when i double click on a command button it populates a number detemrined by a number stated in a separate unrelated textbox.

WHat i want to do rather than manually type in the caption name for each command button is to know if it is possible to loop through all the command buttons named cmd_1 -cmd_200 and enter the name from a query using the Variety Field.

If this is possible i have a second question.

FOr each cmd button do i have to enter a separate double click event or is there a way to say if any cmd button within the 1-200 range is double clickedit will launch a double click event

Code:
me.textbox1 = me.textbox0 'the related textbox

Cheers
 
Do i have to enter a separate double click event or is there a way to say if any cmd button within the 1-200 range is double clickedit will launch a double click event

Have a look at ChrisO's post "Soft-coded event handlers." I understand you can use ChrisO's code to programmatically add an event handler to each of your 200 buttons. I haven't used this code myself, yet!
 
Just out of curiosity...why are you using the Command Buttons' DoubleClick events, instead of their OnClick events? If these buttons have a separate OnClick event, as one might suppose, their DoubleClick events will never fire.

Linq ;0)>
 
Hi. I am trying to use the double click event with the command buttons as each command button will reperesent a product and when it is double clicked it will add to a pick list for despatch. Was using double click rather than single click as thought it would eliminate errorneous accidental clicking on command buttons.

Gizmo. THanks for the link to chris' thread. Very insightful. THink i follow it so will have a play with that one.
 
Gizmo. THanks for the link to chris' thread. Very insightful. THink i follow it so will have a play with that one.

Chris, a very clever chap! I suggest you follow some of his other threads, he was well up there in his knowledge. Interested in all sorts of peculiar aspects of MS Access and VBA. Unfortunately, sadly we lost him about 3 years ago big loss to the forum and MS Access...
 
...Was using double click rather than single click as thought it would eliminate errorneous accidental clicking on command buttons...
Not real sure that'll accomplish your goal, but as long as there's not any OnClick code it won't cause any problem!

Linq ;0)>
 

Users who are viewing this thread

Back
Top Bottom