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 Wanet Telecoms Ltd on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Disabling an option from a frame if a field is equal to a criteria. 1

Status
Not open for further replies.

ffleitas

Technical User
Mar 15, 2001
85
US
Hello programmers,

I have a frame (option group) inside a form with options Monday - Sunday. How would I disable the user from being able to select for example the option Monday if a field on the form equals a certain criteria?


Thanks,
 
use the Forms Load Event, and a Select Case statement to set the appropriate Option/Toggle/CheckBox Enable to False as in this example

Private Sub Form_Load()
Select Case DatePart("w", date)
Case 1 'Sunday
Option15.Enabled = False
Case 2 'Monday
Option3.Enabled = False
Case 3 'Tuesday
Option5.Enabled = False
Case 4 'Wednesday
Option7.Enabled = False
Case 5 'Thursday
Option9.Enabled = False
Case 6 'Friday
Option11.Enabled = False
Case 7 'Saturday
Option13.Enabled = False
End Select

End Sub


This is one way to do it, probably others

PaulF
 
How do I get the function vbMonday to equal the Monday of the current week?
 
vbMonday is a VB constant for 2
so, I'm not sure what it is you're after. But here is an example using the VB Constants

Select Case DatePart("w",Date)
Case vbSunday 'returns 1 for Sunday
Case vbMonday 'returns 2 for Monday
Case vbTuesday 'returns 3 for Tuesday
Case vbWednesday 'returns 4 for Wednesday
Case vbThursday 'returns 5 for Thursday
Case vbFriday 'returns 6 for Friday
Case vbSaturday 'returns 7 for Saturday
End Select

PaulF
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top