Highlight Text If null

  • Thread starter Thread starter jeremy0028
  • Start date Start date
J

jeremy0028

I have the following code in the save command button on my form. A pop
up message tells me i forgot to put address info and will take me to
address field.

If IsNull(Me.Address) Then
MsgBox "Address Required.", , "Missing Information"
Me.Address.SetFocus
Exit Sub
End If

what i want to do is highlight the text box red once user clicks
on address and puts the address the color will change from red back to
the default color of the text box which is white


Any Ideas
 
Jeremy, if it is important to you to check the address has a value, the code
needs to go into the BeforeUpdate event of the *form*, not merely the Click
event of your button. Your button's click can then just force the record
save like this:
RunCommand acCmdSaveRecord
and that triggers the checks in Form_BeforeUpdate.

To answer your question, add the line:
Me.Address.BackColor = vbRed

Then in the AfterUpdate event of the control, you can test it with IsNull(),
and set the control's BackColor back to vbWhite.
 

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

Back
Top