Where to put code?

B

blake7

Hi All, I have the following code which is not working wherever I put it, can
someone help, the processed field is a yes / no selection from a table
containing yes / no value, the duedate field is formatted to a long date. -
or can this be done in conditional format with an expression?
Thanks

If me.Processed="yes" then
me.Duedate.backcolor=vbblue
else
me.Duedate.backcolor=vbred
end if
 
A

Arvin Meyer [MVP]

The code needs to be in the AfterUpdate event of the Processed checkbox or
textbox, and in the form's Current event.

If it is a continuous form you must use Conditional Formatting.
 
D

Dirk Goldgar

blake7 said:
Hi All, I have the following code which is not working wherever I put it,
can
someone help, the processed field is a yes / no selection from a table
containing yes / no value, the duedate field is formatted to a long
date. -
or can this be done in conditional format with an expression?
Thanks

If me.Processed="yes" then
me.Duedate.backcolor=vbblue
else
me.Duedate.backcolor=vbred
end if


A yes/no field will never equal the string "yes". These are boolean
(true/false) fields that have a value of -1 or 0 (or, in some cases, 1 or
0), which is interpreted as True or False. Essentially, any non-zero value
is interpreted as True, while zero is interpreted as False.

In your code, use:

If Me.Processed = True Then

or:

If Me.Processed <> 0 Then

or:

If (Me.Processed) Then
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top