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

Checkbox validation

Status
Not open for further replies.

icsupt

MIS
Jun 14, 2004
150
US
I have a form that has two fields.
[DateTransitioned] (mm/dd/yy format)
[NoTransition] (yes/no format)

If the user checks the [NoTransition] box, I want to grey out the [DateTransitioned] field and so that the user cannot put a date in there. The error message that should appear is "Since you have indicated No Transition, you cannot input a date in Date Transitioned".

Could someone tell me how to do this?

Thanks in advance.
 
Hi
How about:
Code:
Private Sub NoTransition_AfterUpdate()
If Me!NoTransition Then
    Me!DateTransitioned.Enabled = False
Else
    Me!DateTransitioned.Enabled = True
End If
End Sub

If this form refers to a number of records, you will also need to code the On Current event for the form.
 
Thanks for the response. I pasted this code in the AfterUpdate of NoTransition. However, I am still able to enter a date in DateTransitioned.

This form does refer to a table with over 1,000 records. You mentioned OnCurrent event. What do I need to do there to make this work?

Thanks.
 
Hi
Just let me make sure I have this straight. You have lots of records each of which has a possible DateTransitioned or a NoTransition. If so, you would put the same code in the OnCurrent event of the form:
Code:
Private Sub Form_Current()
If Me!NoTransition Then
    Me!DateTransitioned.Enabled = False
Else
    Me!DateTransitioned.Enabled = True
End If
End Sub
This controls the initial entry to each record. The AfterUpdate event then controls changes to the existing state.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top