How do you inactivate a tab control?

arage

Registered User.
Local time
Today, 17:59
Joined
Dec 30, 2000
Messages
537
Based on the value in one tab control, I’d like to set the click property of another tab to not execute at all if the prior tab’s criteria is not met. In my case I said if the computer date isn’t greater than a date on tab1 then any clicking on tab2 will not work or show tab2 at all because the computer date isn’t greater than the value on tab1.
 
This is the code you could use:

If Me.DateField >= Date Then
Me.Tab2.Visible = False
Else
Me.Tab2.Visible = True

If the date field is automatically generated, you could put the code on the OnCurrent Event of the form. If you want to activate the code after the user puts the date in the field, add the code to the AfterUpdate event of the date field. I would put it on the OnCurrent Event as well so that if the user is scrolling through the records, it updates as it goes. I hope I've got the > the right way round - I always have a problem with that!

HTH
Dawn

[This message has been edited by D B Lawson (edited 05-26-2001).]

[This message has been edited by D B Lawson (edited 05-26-2001).]
 
Thanks Dawn, that does help but isn’t necessarily what I’ll be going for. I sort of modified my requirements to simply provide a yes/no msgbox that’ll ask whether or not the user want to continue (based on how much of tab1 they fill out)

The below code worked a single time when I wasn’t paying attention & I’ve been unable to get it to run since. I hate the fact that a single click on a tab doesn’t yield the click event (which calls temp sub below)
I’d like a single click on tabCPR to execute the below but it doesn’t.

'the cpr tab...
Private Sub tabCPR_Click()
Me.CPR_Date.setFocus
Call temp
End Sub

'temp procedure...
Private Sub temp()
'verify user has ALL cpr details to be entered...
MsgBox "Do you have all CPR details required to be input?", vbYesNo, "Error"
'if user clicks no then prevent any cpr details to be entered...
If MsgBox("Do you have all CPR details required to be input?", vbYesNo, "Error") = vbNo Then
MsgBox "You cannot enter CPR details at this time", vbExclamation, "Error"
Me.Page1.setFocus
Exit Sub
End If
End Sub
 
You could try the following:

Private Sub CPRDate_AfterUpdate()
On Error Resume Next

If Me.CPRDate < "Date" Then
Tab2.Visible = True

ElseIf Me.CPRDate > "Date" Then
Tab2.Visible = False


Exit Sub
End If

End Sub
 

Users who are viewing this thread

Back
Top Bottom