Disabling A Textbox If A Condition Is Met

Pharcyde

Arriba Arriba!!!
Local time
Today, 12:24
Joined
Sep 4, 2003
Messages
116
Just a quick&Easy one!

Hey all! Been a while since I've been on here. guess that means I've been doing some work for a change!

I have a form that displays data directly from a table - tblStudentsToAssessments. It goes like this.

Assessment - Result - DateTaken - Assessor - DatePaid

DatePaid applies only if the assessment taken has been failed.

Is there any way that I can disable the DatePaid textbox if the assessments have been passed? What I mean is that I'd only like to enter data in that particular box if the assessment was failed.


Thanks loads, Lee:p
 
try the after update event of the Result field

Then enable or disable the paid field as desired (or hide/unhide or what ever other method you might use)

Regards
 
If Me!Assessment="Passed" Then Me!DatePaid.Enabled=False
Else
Me!DatePaid.Enabled=True
End If
 
Guess the quick&easy was meant for u guys, not for me!

Both replies make sense, but i'm confused as to:

Seth: Where does that code go? Is it macro code, or can i just stick it in the combo box.

cheers, lee:D
 
You are also going to want the code in the "On Current" event if you want the field to be disabled when you open the form or navigate to a new record.

To add the bits of code, open your form in design view, right-click on the little square in the upper left of the form design view, and select 'Properties' from the popup menu.

Select the Events tab and then find the appropriate event(s). Select [Event Procedure] rather than a macro, and then add your code in the VBA window that should now be displayed.

HTH.
 
Awesome! All works asides from 1 thing...

When it sets the field to Disabled, it does it to the rest of the fields as well. The form is in table view, as the students can take many assessments. I would like it to just disable the failed fields/textboxes, but it disables the whole column.

:confused: :confused:

cheers, Lee
 

Users who are viewing this thread

Back
Top Bottom