Cond Format PHONE #

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

Is there a way to set
(000) 000-0000)
with conditional formatting. I have a phone field I would like the default
to be the above BUT I would like the field to be red to remind the person to
enter the number.

Thanks
 
Hi

Yes you can either use conditional formating to do this - click the field
and then Format tab. Select conditional formating and set the "Field Value
is" - "Equall to" then insert "(000) 000-0000)"
Are you sure about the bracketing as it looks wrong ??

Or (to get more options on color) you could use the OnLoad and AfterUpdate
events like this

Private Sub FieldName_AfterUpdate()
Private Sub Form_Load()
"Use one of above"

If Me.FieldName = "(000) 000-0000" Then
Me.FieldName.ForeColor = vbBlack
Me.FieldName.BackColor = vbRed
Else
Me.FieldName.ForeColor = vbBlack
Me.FieldName.BackColor = vbWhite
End If
End Sub

Hope this helps
 
Thanks I thought I had tried that but like you said extra ) in the format was
the problem. One more question is there a way to set the field to a different
color if it has "no value" as you exit the form if they have missed a field
using what you have below? How do I tell it to look at certain fields? Or
should I post this as a different question? Like how do you set missed
required fields to a diffent color and pop up a msg? <grin>
Thanks!!
 
Lmv,

If you are using the Conditional Formatting approach, you can set a
condition using...
'Expression is...' [YourControl] Is Null
.... and set up the colour accordingly.

If you are using the code approach, as suggested by Wayne:

If Me.ControlName = "(000) 000-0000" Then
Me.ControlName.BackColor = vbRed
ElseIf IsNull(Me.ControlName) Then
Me.ControlName.BackColor = vbYellow
Else
Me.ControlName.BackColor = vbWhite
End If

However, I wouldn't expect the Exit event of the form would be correct.
I mean, after you exit the form, you can't see it, so it doesn't
matter what clour it is! Nor would I use the form's Load event as
suggested by Wayne either. I think you would need the code on the
Current event of the form, and also the After Update event of the control.

Myself, I would use Conditional Formatting.

By the way, in this context the meaning is clear, but please note that
forms do not have fields. Fields are in tables and queries, and the
field values are displayed on forms via controls. Probably a good idea
to get in the habit of using 'control' as it can be confusing otherwise
in other contexts. :-)
 
Thanks Steve (and Wayne)

I will work on the "controls" ;) and see what I can accomplish.

but I am sure "I'll BE BACK" (if not this question on another. I SOOOO
apreciate all of the things I have learned on this board. Including accurate
terms so my questions will make sense!!)

Thanks again!

Steve Schapel said:
Lmv,

If you are using the Conditional Formatting approach, you can set a
condition using...
'Expression is...' [YourControl] Is Null
.... and set up the colour accordingly.

If you are using the code approach, as suggested by Wayne:

If Me.ControlName = "(000) 000-0000" Then
Me.ControlName.BackColor = vbRed
ElseIf IsNull(Me.ControlName) Then
Me.ControlName.BackColor = vbYellow
Else
Me.ControlName.BackColor = vbWhite
End If

However, I wouldn't expect the Exit event of the form would be correct.
I mean, after you exit the form, you can't see it, so it doesn't
matter what clour it is! Nor would I use the form's Load event as
suggested by Wayne either. I think you would need the code on the
Current event of the form, and also the After Update event of the control.

Myself, I would use Conditional Formatting.

By the way, in this context the meaning is clear, but please note that
forms do not have fields. Fields are in tables and queries, and the
field values are displayed on forms via controls. Probably a good idea
to get in the habit of using 'control' as it can be confusing otherwise
in other contexts. :-)

--
Steve Schapel, Microsoft Access MVP
Thanks I thought I had tried that but like you said extra ) in the format was
the problem. One more question is there a way to set the field to a different
color if it has "no value" as you exit the form if they have missed a field
using what you have below? How do I tell it to look at certain fields? Or
should I post this as a different question? Like how do you set missed
required fields to a diffent color and pop up a msg? <grin>
Thanks!!
 

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

Similar Threads

Convert number 2
Microsoft access 2
need to search phone numbers 2
Format Problem 9
Format text box with check box 1
simple format question 3
Phone Number Formatting 8
Defaul area code 2

Back
Top