assessing a string value to be a phone number

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
 
J

John Spencer

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
'====================================================
 
S

Southern at Heart

WOW! That's EASY! THANKS! This looks like a statement from a query, but
it'll work in VBA?
thanks so much!
SatH
 

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