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

Automatically Enabled and Disabled Checkbox

Status
Not open for further replies.

DDTiff

MIS
May 29, 2002
48
0
0
US
Hello,

Can someone please help me? I have a question about checkbox enabled and disabled capability. I would like to thank you in advance for your help.

I have a table call 'Items' with 'Status'; 'Due Date'; 'Overdue' and many other fields, but the condition only involves Status; Due Date; and Overdue. The Overdue field has a 'Yes/No' Datatype

I made a form using the 'Items' table and I would like the 'Overdue' checkbox to be disabled if the Status textbox value is equaled to "Closed" else enabled 'Overdue' checkbox if Due Date is less than Today's date.


Pseudocode

Private Sub chkOverdue_Change()
If txtStatus = "Closed" then
chkOverdue.checked=False
Else
If Due Date < Today Date then
chkOverdue.checked=true
End if
End if
End Sub

Once again, thank you for your help.
 
I'm not sure if this is exactly what you want, but:

Code:
Private Sub chkOverdue_Change()

If txtStatus = "Closed" then
    chkOverdue.checked=False 'This will uncheck the Overdue box, right?
    chkOverdue.Enabled = False
Else
    If Due Date < Today Date Then
    	chkOverdue.Enabled = True
        chkOverdue.checked=true
    End if
End if
End Sub

If you want to disable the check box, set the .Enabled property to FALSE. If you want to UNCHECK the box, set the .CHECKED property to FALSE. I don't know if you can uncheck a disabled checkbox, so test the order of the code. You might have to switch the order of the lines.

Thanks!!


Matt
 
Matt,

Thank you for response, but the code did not work because I want the checkbox to check and uncheck automatically when one of the condition is true or false. I wall try using Status_AfterUpdate & Status_BeforeUpdate (these two are not applicable to checkbox)event but that still did not work. Is there a work around way you could provide me. Thank you ahead of time for your help.
 
To set a checkbox true or false, just code it:


chkOverdue = True

or

chkOverdue = False

I'm sorry. I don't believe there's a .checked property for a checkbox.

Thanks!!


Matt
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top