Conditional Formatting forces user to click twice to move to another record

missinglinq

AWF VIP
Local time
Today, 03:48
Joined
Jun 20, 2003
Messages
6,420
Was writing a little routine for someone who needed, with a datasheet or
continuous form, to have FieldTwo's back color change when FieldOne has focus. I added a boolean field, FFlag, and set it with the following code:

Code:
Private Sub FieldOne_GotFocus()
  Me.FFlag = -1
End Sub
Code:
Private Sub FieldOne_LostFocus()
  Me.FFlag = 0
End Sub
and then used Conditional Formatting for FieldTwo

Expression Is [FFlag] = -1

with the back color set as desired.

This works as expected with one exception. If you move to another control
within the current record, everything works correctly. But if you try to move
to a different record with the mouse, the formatting disappears from FieldTwo, but the cursor stays on the FieldOne of the current record! In order to go to another record you have to click on it a second time!

I've tried everything I can think of, including recreating the scenario with
a new db, made from scratch, in case it was some weird type of corruption,
with no luck.

If the Conditional Formatting is removed, the form works as it normally would!

Anyone with any ideas?

Running Access 2003/SP2 on Windows XP

Thanks!

Linq
 
How about using the SendKeys command (to activate TAB or Enter key)
in your OnClick event? Not sure this will work for you, but worth trying.
 
How about using the SendKeys command (to activate TAB or Enter key)
in your OnClick event? Not sure this will work for you, but worth trying.

Aside from SendKeys being evil and something to be avoided like the plague, the OnClick event of what? The user could move to a different record by clicking on any control in the record. And if the click event on a control triggered a move to another record, how would the user click into the control in order to enter data into it?
 
I would have thought you lost your formatting when you moved to another control because of LostFocos = 0 and thus shouldn't you lose it when going to another record.

The issue of "two clicks" I have had that a couple of times when a macro is run from and OnClick on a textbox but I can't remember where they were.

It might be because of the LostFocus action having to be done first and the second click is OK because the LostFocus has been done.
 
Modified a form in a little test DB , used a checkbox testing for True/False, noproblem, I can move between records with 1 click, all works as you require.

Using 2003 SP3

Brian
 
Ah! I had a thought, my checkbox was unbound, so switched to another field that was bound and Bingo! it behaves like yours, with the unbound field being tested the conditional formatting applied to all records which is what made me think I was not doing exactly the same as you.

I think that Mike is correct if the Lost focus event exists but does nothing you move ok, but as soon as it has to do an action affecting the Table you need 2 clicks.

Brian
 
Thanks everyone for your help! As I said, I was doing this to try and help a poster elsewhere, but it'll have to go on the back burner for now! If I should stumble on the answer later, I'll post it back here!

Linq
 

Users who are viewing this thread

Back
Top Bottom