A button for closing the form should be drawn outside the tabstrip area

The tabs can also be moved around the strip. This is done by changing the TabOrientation property. The tabs can be at the top, bottom, left, or right side of the userform:

The following lines of code were used to create the tabstrip form in Figure 21.4. The Initialize sub calls the sub, SetValuestoTabStrip, that sets the value for the first tab.

Private Sub UserForm_Initialize() SetValuesToTabStrip 1 'As default End Sub

These lines of code handle what happens when a new tab is selected.

Private Sub TabStrip1_Change() Dim lngRow As Long lngRow = TabStripl.Value + 1 SetValuesToTabStrip lngRow

End Sub

This sub provides the data shown on each tab. A sheet was set up, with each row corresponding to a tab.

Private Sub SetValuesToTabStrip(ByVal lngRow As Long) With frm_Staff

,lbl_Name.Caption = Cells(lngRow, 2).Value .lbl_Phone.Caption = Cells(lngRow, 3).Value ,lbl_Fax.Caption = Cells(lngRow, 4).Value .lbl_Email.Caption = Cells(lngRow, 5).Value ,lbl_Website.Caption = Cells(lngRow, 6).Value .Show End With End Sub

The tabstrip's values are automatically filled in. They correspond to the tab's position in the strip; moving a tab changes its value.

0 0

Post a comment