Access:can empty form fields show color to alert that there's no d

R

rogersa

I am building a data-intensive form in Access and would like to have empty
form fields highlighted either by a colored border or colored field. Is this
possible? If so, how do I go about making it happen? I am not hugely
experienced in Access, but have been mucking about with it for nine years.
 
D

Damon Heron

You could try something like this, assuming all your fields are textboxes.

Private Sub Form_Load()
Dim varctl As Control
For Each varctl In Me.Controls

If (TypeOf varctl Is TextBox) Then
varctl.SetFocus
If varctl.Text = vbNullString Then
varctl.BorderColor = vbRed
End If

End If
Next varctl

End Sub
********************
Then, in each textbox beforeupdate event:

Private Sub Text0_BeforeUpdate(Cancel As Integer)
If Me.Text0.Text <> vbNullString Then
Me.Text0.BorderColor = vbBlack
End If

Damon
 
A

Albert D. Kallal

rogersa said:
I am building a data-intensive form in Access and would like to have empty
form fields highlighted either by a colored border or colored field. Is
this
possible? If so, how do I go about making it happen? I am not hugely
experienced in Access, but have been mucking about with it for nine years.

Access 2000 and later has a feature called conditional formatting. So you
can accomplish this without any code at all.


Just bring up the form in design mode, and click on a text box. in the menu,
simply select conditional formatting.

For the formatting use:

Expression is IsNull([Catagory])

The above "expression is" is a list in a combo box of possible
settings/conditions you can use for the text box, and then type in the
IsNull([name of field]).

You can bold, or even have a nice pale light blue for the tex box
background.

So, yes this can be done...and done without code....
 
A

Albert D. Kallal

Damon Heron said:
You could try something like this, assuming all your fields are textboxes.

Private Sub Form_Load()

....

Unfortunately, the form load only occurs once. during data entry the person
may be entering MANY records. And, they certainly can/may navigate to
previous records to check out what work they done already. So, it likely not
very practical to attempt this code in the on-load event.

See my other post...you can do this kind of thing with conditional
formatting..and it even works in continues forms (and, you don't have to
write one line of code).
 
D

Damon Heron

Albert, You are right as usual. My code could go in the on current event,
but conditional formatting is preferable, with the exception that you can't
do border colors with it. From the OP, I was picturing a questionnaire (for
some reason, known only to my unconscious) that had a large number of
textboxes that had to be filled in by the user. Chalk it up to brain
freeze!

Damon
 

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