assessing a string value to be a phone number

  • Thread starter Thread starter Southern at Heart
  • Start date Start date
S

Southern at Heart

I need to check to see if strPhone is a phone number with this format:
xxx-xxx-xxxx
It has to be this way or it won't work in the code further down the line
(which I can't change)

I can remove spaces from the beginning and end of it if they exist using
Left & Right fucntions. But is there a way to verify that the 4th and 8th
char is the hypen, and that all the other chars are digits?
many thanks,
SouthernAtHeart
 
IF Trim(StrPhone) Like "###-###-####" Then


'====================================================
John Spencer
Access MVP 2002-2005, 2007-2008
Center for Health Program Development and Management
University of Maryland Baltimore County
'====================================================
 
WOW! That's EASY! THANKS! This looks like a statement from a query, but
it'll work in VBA?
thanks so much!
SatH
 
Back
Top