Use check box to populate a text box

B

Bill Davis

I have a check box on my form and when it is check i want
to display "Pending" in the text box below it and display
it in red. Is this possible?
Thanks in advance
 
J

Jeff Boyce

Bill

In the AfterUpdate event of the checkbox, add code that sets the text and
color of your text message.

It would look something like (actual syntax may vary):

If Me!chkMyCheckBox = True Then
Me!txtMyTextMessage = "Pending"
Me!txtMyTextMessage.ForeColor = vbRed
ElseIf Me!chkMyCheckBox = False Then
Me!txtMyTextMessage = ""
Else
'handle this error
End If

Good luck!

Jeff Boyce
<Access MVP>
 
B

Bill Davis

Jeff,
When a box is check it displays Pending for all the
records and when i remove the check it removed it from
all records. Any ideal of what I am doing wrong?
Bill
 
J

Jeff Boyce

Bill

Are you working with a datasheet view? Is (as Damon asks) the checkbox
unbound or bound?
 
J

Jeff Boyce

Lou

Please re-read my previous post -- are you using a single-form or datasheet
view?
 
G

Guest

Jeff,
I am using a single-form view. I tried it with a combo
box and it does the same thing.
 
J

Jeff Boyce

If the check box is bound to a field in an underlying table, and the form is
a single record view, how can you tell that checking the box changes ALL
records? Are you saying that the check box remains checked on each record's
view via the form, or are you saying that checking the box updates EVERY
record in the table?

To what kind of underlying field is the checkbox bound (traditionally, it
would be a Yes/No field).
 
G

Guest

Jeff,
I am sorry, it is not the check box it is the text in the
text box that shows for all the records.
 
J

Jeff Boyce

You have an unbound text box on your form that you set one time, and then it
shows the same thing no matter what record you display in the form. That
sounds right.

If you want the unbound text box to reflect the value in the checkbox/field
of a current record, you need to re-evaluate that checkbox value every time
the record changes.

What code are you using now to re-evaluate (and re-set)?
 
G

Guest

Jeff,
Please excuse my ingorance but I am teaching myself. I
am using the code you provided. I was thinking it was
ehe ElseIf statement would re-set the text box.

If Me!chkMyCheckBox = True Then
Me!txtMyTextMessage = "Pending"
Me!txtMyTextMessage.ForeColor = vbRed
ElseIf Me!chkMyCheckBox = False Then
Me!txtMyTextMessage = ""
Else
'handle this error
End If
 
J

Jeff Boyce

Yes, this will set the text message box, once each time it is run. How many
times are you calling it to run? Via which event(s)?
 
G

Guest

Jeff,
I am have the code under the AfterUpdate event. I will
need it to run for each record.
Not all records will have a pending status.
 
J

Jeff Boyce

AfterUpdate of what? The form, the checkbox, ??? I'm feeling a little
lost.

The basic concept is that you have a control on a form that is bound to a
field in a table. Every row in the table has a value in that Yes/No field.

So every row, when displayed in a form, needs to have that field inspected
and the "pending" message set. You'd need to use the Current event to
evaluate for each (current) record. AND, you'd need to evaluate in the
AfterUpdate event of the checkbox control.
 

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