Hey guys, i got a enquiry here, cant figure it out myself.
I got a textbox field that validates what users input, if the users enters, lets say, less than 10, then the back color of the texfield will turns red, and if the users enter more than 10, it will be reverted back to normal(white background). I wanted the color be be reverted back to normal when the users click to a fresh next record(sort of like clear every fields) and the color will still be red when i previous back the record which fails the validation rule(<10).
Private Sub textbox_AfterUpdate()
if textbox < 10 then
textbox.BackColor = vbRed
text box.BackColor = vbWhite
Currently i am stuck at when users click a fresh new record, the background is still red in the fresh new record.
One button to add a new record, the other to go to the previous record. Turn off the navigations buttons down at the bottom of the form so that the user can only use the command buttons for navigation.
The Add new record button your code should look like this
Private Sub new_record_Click()
On Error GoTo Err_new_record_Click
The Previous record coding will take you to the previous record
Now the On Current event will need to have the following coding
Private Sub Form_Current()
If (test_field < LowerLimit) Or (test_field > UpperLimit) Then
test_field.BackColor = vbRed
test_field.BackColor = vbWhite
Your textbox coding will remain the same, I have added some brackets to group the conditions, just a safety feature that I use.
Private Sub Textbox_AfterUpdate()
if (Textbox < LowerLimit) or (Textbox > Upperlimit) then
Textbox.BackColor = vbRed
Textbox.BackColor = vbWhite