Conditionally format a label object or a toggle button

J

Jeff @ CI

In A2K - on a form. Wanting to create a simple (I hope) control to indicate
whether the work on a record is done or not.

If the user has completed work on the record, I would like the user to click
a control (thinking a toggle button works best here) and the record would
have a label's text change from either "Not Done" to "Done" or change color
from the background (and therefore seemingly transparent) to ... say - red.

I am thinking that I will need to do an OnClick event procedure in which the
text is assigned one of two colors or one of two phrases depending on if the
toggle is "on" or "off". Sadly, I do not know any VBA yet other than popular
and often used commands - yet.

The purpose is to help those - currently two - who use this form to readily
identify if the other has worked a record or not. With this in mind, I
intend to use a Me.Refresh as the last line of the code so that they are
constantly updating the data displayed in their form.


Any help or ideas - Thanks in advance!!!

Jeff
 
A

Arvin Meyer [MVP]

Since you will probably want this to reside with the record, add a Boolean
(yes/no) field to the underlying table, and bind a toggle button control to
that. Then use code like:

Private Sub tglDone_Click()
If Me.tglDone = True Then
Me.tglDone.Caption = "Done"
Else
Me.tglDone.Caption = "Open"
End If
End Sub

And in the Form's Current event add this code to call the toggle button
code:

Private Sub Form_Current()
tglDone_Click
End Sub
 

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

Similar Threads


Top