checkbox

skate

Registered User.
Local time
Today, 19:30
Joined
May 22, 2002
Messages
136
How do you set a check box to "yes" for only a specific record using code?
 
You can say

Me.chkBoxName = somecondition

where somecondition is an expression that evaluates to a True when you want the check box checked, and false otherwise. For example, if you wanted the check box to mean AccountIsOverDue you could write

Me.chkOverDue = (Me.AccountBalance>0) And (Me.DueDate<Date)

This line would have to be placed in some event or other, depending on the meaning of the check box and whether the user action on the form could change it. If the user could (in this example) change the DueDate, you might set the value in the form's OnCurrent event and also in the DueDate's AfterUpdate event.

Again, where you put the code depends a lot on what you are trying to show, and what data impacts the value of the check box.

Just a thought - if you are trying to provide a visual impact when certain events occur you might want to consider changing the ForeColor of the text box containing the value you want to highlight. For example:

If (Me.AccountBalance>0) And (Me.DueDate<Date) then
Me.AccountBalance.ForeColor = 255
Else
Me.AccountBalance.ForeColor = 0
End If

would set the forecolor to red if the acount is overdue, black otherwise. You could also change the BackColor, the font weight, or other properties. you get the idea!

Jim
 
If [yourcondition] = true then
checkbox = -1 'ticked
else
checkbox = 0 'unticked
end if

yourcondition could be DateField<Date-30 or whatever

HTH
Dave
 

Users who are viewing this thread

Back
Top Bottom