You can use the tab control's "On Change" event.
Here's how.
In my example:
Tab1 is a tab page control with two pages on it
also Txt1 is an unbound textbox on the same form.
Change my code or your controls to match.
Click in the upper right of the tab control. The name of your whole tab control should display in the Properties Dialog box ( Important ! - not the name off the individual pages within the tabe control)
Click the "Events" tab of the Properties Dialog box.
You will see a list of events. Choose "On Change"
click right on the words "On Change".
Then click on the little button with three dots on it ... to the right
Select "Code Builder" from the dialog box that pops up, and OK it
You will see these words pop up in the Code Builder Window that follows.
Private Sub Tab1_Change()
End Sub
Add the text below between those two lines:
Dim str1 As String ' str1 is text
Select Case Tab1.Value ' look at the value of the whole tab page control
Case 0 ' tab page indexing begins with "0", not 1
str1 = "1/1/1999"
Case 1
str1 = "1/1/2000"
End Select
MsgBox str1 ' str1 will display in a messagebox
Txt1 = str1 ' Txt1 is set to str1
It should then read as:
Private Sub Tab1_Change()
Dim str1 As String ' str1 is text
Select Case Tab1.Value ' look at the value of the whole tab page control
Case 0 ' tab page indexing begins with "0", not 1
str1 = "1/1/1999"
Case 1
str1 = "1/1/2000"
End Select
MsgBox str1 ' str1 will display in a messagebox
Txt1 = str1 ' Txt1 is set to str1
End Sub
Use whatever names you need for the controls. Use those same names in the code.
Best..
C
|