Highlight required fields ?Code not working

By eckardtk ·
The following link/ article recommends putting code both in the On Current Property and the After Update Event Property. The code is the same for both properties. It should highlight the required field while it is empty and then the background colour should revert back to white when data have been entered.

I copied the code (shown below) as is. Unfortunately, the required field stays red even after data have been entered.

I understand so little about code that I have no idea how to make this work as planned. Any suggestions ?

The link:

The recommended code:
If IsNull(ContactTitle) = True Then
ContactTitle.BackColor = vbRed
ContactTitle.BackColor = vbWhite
End If

ALSO, this code seems to be good only for one field ? I have several required fields. Could I replace ?ContactTitle? from the sample with a string of (Field1;Field2;Field3; .. etc.)? Do I use commas, semicolons or colons as separators ?

This conversation is currently closed to new comments.

Thread display: Collapse - | Expand +

All Answers

Collapse -


by Tony Hopkinson In reply to Highlight required fields ...

That's a bit naughty

Is ContactTitle the column, or the TextBox?

Try giving your textboxes a prefix e.g. tb_ or somesuch.

I would have expected the IsNull test to be on the column, but checked on a new record (Form_Current) or a change tb_MyColumn_AfterUpdate.

As for doing more than one test,

In Form Current it would be

If ISNull(Column1)...

If IsNull(Column2)...

and thene an After_Update event handler for each text box.


Related Discussions

Related Forums