Change font color on a command button

G

Guest

Hello,

I have a project form which shows a record for each project. On that form I
have a subform which shows, in continuous form view, all the tasks for each
project. I have a command button which shows up beside each task (ie. if
there are two tasks per project record, then there are two command buttons,
if there are eight tasks, then eight command buttons). This command button,
cmdComments, when clicked on brings up a popup form which has a field from
the subform within it. That field is called TaskJournal and it allows the
user to add or view comments for each task.

The command button, cmdComments, has the letter "i" on it. What I want to
do is have each command button's letter "i" be black if there are no comments
for a task, and be red if there are comments. Is there any way to do this?
Right now I have the code:

Private Sub Form_Current()

If Not IsNull(Me!TaskJournal) Then
Me.cmdComments.ForeColor = vbRed
Else
Me.cmdComments.ForeColor = vbBlack
End If
End Sub

But what this does is if there are comments for one task amongst eight, all
the command buttons' letter "i"s show up red and if there are no comments for
a record (when on that record) they all show up black. I need each command
button to show red or black for its corresponding task at all times. I hope
someone can help with this.

Thanks,
Janet
 
S

Steve Schapel

Janet,

As far as I know, this is not possible.

With a bit of a fiddle around, however, you can put a textbox instead of
a command button, and format it so it looks *almost* like a command
button. Then you can use Conditional Formatting of the textbox to get
the red/black switch.
 
M

Marshall Barton

JanetF said:
I have a project form which shows a record for each project. On that form I
have a subform which shows, in continuous form view, all the tasks for each
project. I have a command button which shows up beside each task (ie. if
there are two tasks per project record, then there are two command buttons,
if there are eight tasks, then eight command buttons). This command button,
cmdComments, when clicked on brings up a popup form which has a field from
the subform within it. That field is called TaskJournal and it allows the
user to add or view comments for each task.

The command button, cmdComments, has the letter "i" on it. What I want to
do is have each command button's letter "i" be black if there are no comments
for a task, and be red if there are comments. Is there any way to do this?
Right now I have the code:

Private Sub Form_Current()

If Not IsNull(Me!TaskJournal) Then
Me.cmdComments.ForeColor = vbRed
Else
Me.cmdComments.ForeColor = vbBlack
End If
End Sub

But what this does is if there are comments for one task amongst eight, all
the command buttons' letter "i"s show up red and if there are no comments for
a record (when on that record) they all show up black. I need each command
button to show red or black for its corresponding task at all times. I hope
someone can help with this.


Ahh, that's different than your other post with this
question. On a continuous form, you need to use Conditioal
Formatting to have each record display differently.
Unfortunately, you can not use CF on a command button.

Try changing the command button to a locked text box with
the raised special effect. Then you can use CF to get the
desired effect.
 
S

Steve Schapel

Janet,

By the way, if you use the textbox idea, it can work quite well to use
the Enter event of the textbox to open your TaskJournal popup form. At
the same time, add code to this procedure to move the focus to another
control on the subform... otherwise you end up with the cursor in your
"command button", which looks odd.
 

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