Form_Current is always a step behind

krausr79

Registered User.
Local time
Today, 02:17
Joined
Oct 5, 2012
Messages
26
I'm trying to change a textbox color on my form based on whether a box is checked in the record. The display is off, though the color I want is always displayed for the record I was just at:

What I want:
checked? Color
chk pink
chk pink
chk pink
not white
chk pink
not white
not white
not white

what I get:

checked? Color
chk pink
chk pink
chk pink
not pink
chk white
not pink
not white
not white

Code:
Private Sub Form_Current()
 
If Me.CI.Value = True Then
    Me.txtComments.BackColor = RGB(255, 180, 255)
Else
    Me.txtComments.BackColor = RGB(255, 255, 255)
End If
End Sub

This is not specific to color changes, either. When working with this form earlier, I was copying text from the record into a textbox, but always got the text from the record which was previously selected, and not the text from the record currently selected.

Is form_current like a 'before' event? Should I be using a different event?
 
Use the after_update event of the check box.
 
I think you should be using Conditional Formatting.

Use the Expression Is option.
 
Generally speaking, for this kind of thing, you would use the AfterUpdate event of the Checkbox, as Cronk suggested, as well as the Form_Current event, if you are talking about a Single View Form. But for a Continuous or Datasheet View Form you'd have to use Conditional Formatting, as Galaxiom suggested.

If this Form is one of the latter two views, I suspect that the 'selected' or Current Record is not the one you think it is (which occurs on a fairly frequent basis) or the Form is corrupted.

How, exactly, were you copying the text; using the keyboard/mouse or through code?

Linq ;0)>
 
Thank you. This is a split form with datasheet and single-form looks on the same screen. My friend had me do this with conditional formatting, so that is how we've solved it. I will try to bear in mind that non-single view forms can misbehave. I had also run into the problem where my label would not change colors, so I had to switch to a textbox.
 
Conditional Formatting isn't available for Labels, of course, but using Textboxes like this is a common workaround.

Glad you got it working!

Linq ;0)>
 

Users who are viewing this thread

Back
Top Bottom