Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

using command buttons

Status
Not open for further replies.

orisons

Programmer
Feb 18, 2002
49
CA
I have set up quite a few command buttons as control arrays, this was so I could use a do loop to assist the user in renaming the control caption, the problem is when I click on cmd_button(0) to open a specific form the same happens when I click on cmd_button(1) is there any way around this without losing the loop for renaming.

please remember in you reply that I am reasonably new at this
 
The click event for your command button should be something like...

Private Sub cmd_button_Click(Index as Integer)

When the Zero'th button is clicked, index will = zero, when the next button is clicked, the index will be 1.

So you can do something like....

Code:
Private Sub cmd_button_Click(Index as integer)

  Select case Index
    Case 0
      msgbox "First Button Clicked"
    Case 1
      MsgBox "Second Button Clicked"
    Case Else
      Msgbox "Un-Handled button clicked"
  End Select
End Sub

-George

Strong and bitter words indicate a weak cause. - Fortune cookie wisdom
 
Code:
Private Sub Command1_Click(Index As Integer)

use the index value to execute code you desire

If somethings hard to do, its not worth doing - Homer Simpson
 
oops.. double post.. my bad :(

If somethings hard to do, its not worth doing - Homer Simpson
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top