Input mask with 2 possibilities?

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

Guest

For a phone field I want to allow 1) a number such as 800-123-1234 and 2)
text as 'No-Call'. Can you have 2 possible masks?
Thanks,
 
Doug F. said:
For a phone field I want to allow 1) a number such as 800-123-1234 and 2)
text as 'No-Call'. Can you have 2 possible masks?

No. That's one of the many limitations of input masks (which I don't
consider particularly useful in the first place!)
 
Hi, Doug.
Can you have 2 possible masks?

No. But really, you have two items of information for this record, not just
one. One is the phone number and the other is whether or not the number is
allowed to be called. I would suggest creating an additional field with a
Boolean value for whether the phone number is allowed to be called. Add VBA
code to the form's OnCurrent( ) event that disables the phone number text box
(greys it out) whenever the "No Call" field is true and enables this text box
whenever the "No Call" field is false.

HTH.
Gunny

See http://www.QBuilt.com for all your database needs.
See http://www.Access.QBuilt.com for Microsoft Access tips.

(Please remove ZERO_SPAM from my reply E-mail address so that a message will
be forwarded to me.)
- - -
If my answer has helped you, please sign in and answer yes to the question
"Did this post answer your question?" at the bottom of the message, which
adds your question and the answers to the database of answers. Remember that
questions answered the quickest are often from those who have a history of
rewarding the contributors who have taken the time to answer questions
correctly.
 
Doug F. said:
For a phone field I want to allow 1) a number such as 800-123-1234 and 2)
text as 'No-Call'. Can you have 2 possible masks?

As the others have suggested, there can only be 1 Input Mask. You can use
the Before Update event to code almost any type of input mask you wish by
building a case statement to evaluate other conditions and create the
changes "on the fly". The following function is an example of building
format for a phone number. Though not strickly an input mask, (it merely
formats) it is similar to code that can be written that way. (Note: The
error handling, or lack thereof, is in place because this function is also
used in a query)

Public Function FormatPhone(strIn As String) As Variant
On Error Resume Next

If InStr(1, strIn, "@") >= 1 Then
FormatPhone = strIn
Exit Function
End If

Select Case Len(strIn & vbNullString)
Case 0
FormatPhone = Null
Case 7
FormatPhone = Format(strIn, "@@@-@@@@")
Case 10
FormatPhone = Format(strIn, "(@@@) @@@-@@@@")
Case 11
FormatPhone = Format(strIn, "@ (@@@) @@@-@@@@")
Case Else
FormatPhone = strIn
End Select

End Function
--
Arvin Meyer, MCP, MVP
Microsoft Access
Free Access downloads:
http://www.datastrat.com
http://www.mvps.org/access
 
Back
Top