Conditional Formate

C

Chey

I want to run a macro, that when you click on that field in that form then
the field fild will turn red and the text white.
Can some one help me.
Thanks
Chey
 
A

Al Camp

Chey,
I'd suggest the OnEnter event. That would work with tabbing into the field, or
clicking it.
YourTextField.Forecolor = QBColor(15)
YourTextField.BackColor = QBColr(4)
Use the OnExit event to return the colors to their normal value.
 
C

Chey

Okay that didn't work for me. What I am going for is when I click on it it
changes color and stays that way.
How about one click, text turns red
double click turns black.
I am showing that I have reconciled that amount. When I used the code below
it worked but turned every record to that. I just want that one field in the
record.
Thanks
 
B

bobocat

Hi Chey,

I tried to make 2 macros:

1. Name clickMacro on Event Click
Action: SetValue
Item: [Forms]![FormName]![FieldName].[ForeColor]
Expression: 255

2. Name: DblClickMacro on Event Double Click
Action: SetValue
Item: [Forms]![FormName]![FieldName].[ForeColor]
Expression: 0

If you want to restore the color after you leave the field
3 Name: restoreMacro on Event Lost Focus
Action: SetValue
Item: [Forms]![FormName]![FieldName].[ForeColor]
Expression: 16711680 (say blue color)

is that OK?
 
A

Al Camp

Chey,
You won't be doing that with a Click or DblClick.
Changing the color of a field with a Click would change the color of that field for all
records during that session. When the form is reopened later, that field revert to the
color designated in Design mode. Also, during a session, that field will have the same
color on all records.

We need a field that will store the "status" of that text control, so we can
"logically" color the field accordingly... on the fly for each record.

Add a field to your table called Reconciled, make it a Yes/No (format = True/False)
field. This will be a checkbox on the form. (ex. name chkReconciled)
When a record has been reconciled, click the Reconciled checkbox. That in itself
should be enough for the user to see that this record has been reconciled. but if you
still need to change the color of a field accordingly, use this code on the AfterUpdate
event of chkReconciled...
(use your own control names)

Private Sub chkReconciled_AfterUpdate()
If chkReconciled = True Then
YourFieldName.Forecolor = QBColor(12) 'Light Red
Else
YourFieldNAme.Forecolor = QBColor(0) 'Black
End If
End Sub

Also, we'll have to decide on the appropriate color each time we come to a record
(browse).
Place the same code as above in the Current event of the form itself.

When you check Reconciled, the color will change to Red, when you uncheck Reconciled it
will return to Black (toggling)
Access can not "remember" if a text control has been clicked or not, so that Reconciled
"status"
 

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