> Gary was telling us:
> Gary nous racontait que :
>
> > I have a userform setup with a multipage control. I have various
> > textboxes that need to be filled out for various information. I have
> > also included a option button (copyhpm2) which will allow me to do a
> > quick subroutine and then allow me to update the text of a box.
> >
> > My issue is that I would like to be able to find out which button has
> > been pushed. (I know I could hardcode this with a variable, but there
> > are a lot of these).
> >
> >
> > As another footnote, how can I determine the next, or previous, text
> > box in the tab order programatically.
>
> Try these:
>
> '_______________________________________
> Private Sub CommandButton1_Click()
>
> MsgBox "My name is """ & Me.ActiveControl.Name & """."
>
> End Sub
> '_______________________________________
>
> '_______________________________________
> Private Sub TextBox2_Change()
>
> Dim lngTabID As Long
> Dim lngTabIDNext As Long
> Dim strControlName As String
> Dim ctrlTab As Control
>
> lngTabID = Me.ActiveControl.TabIndex
> lngTabIDNext = 0
>
> For Each ctrlTab In Me.Controls
> If TypeOf ctrlTab Is TextBox Then
> With ctrlTab
> If .TabIndex > lngTabID Then
> If lngTabIDNext = 0 Then
> lngTabIDNext = .TabIndex
> strControlName = .Name
> ElseIf .TabIndex < lngTabIDNext Then
> lngTabIDNext = .TabIndex
> strControlName = .Name
> End If
> End If
> End With
> End If
>
> Next
>
> If strControlName <> "" Then
> MsgBox "The next textbox in the tab order is """ _
> & strControlName & """."
> Else
> MsgBox "This is the last textbox in the tab order."
> End If
>
> End Sub
> '_______________________________________
>
> --
> Salut!
> _______________________________________
> Jean-Guy Marcil - Word MVP
> jmarcilREMOVE[ at ]CAPSsympatico.caTHISTOO
> Word MVP site:
http://www.word.mvps.org