Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chris Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

This is killing me.. phone number input mask 1

Status
Not open for further replies.

EzLogic

Programmer
Aug 21, 2001
1,230
US
I have always used a field for phone numbers with chr(12) as the width, so data is stored as such: 313-555-1212

I moved my data to SQL server (still experimenting) and i decided to make the field char(10), and saved it like this: 3135551212 (basically saving 2 characters per record..)

Now on the Grid, i list all the phone number search and i want to display the data like this: 313-555-1212, though data saved is: 3135551212

I played with the Column's inputmask (999-999-999 and ###-###-####) and the Format.. but, it's eating up the characters..
it displays it like this: 313-55-212 (etc..) basically where the - is, its taking over the number..

is there a way around this? or do i have to "stuff" the "-" (dashes) in my SQL stored procedure just before i return the cursor to add the dashes?




Ez Logic
Michigan
 
I guess, i solved it like this... but, i still like to know if there is another way.

Code:
Alter procedure sp_SearchCellularByKeyword
	@tcKeyword VARCHAR(50), 
	@tnfk_Store int 

as 

select TOP 1000 
	cellCust.custno,
	cellular.serial,
	cellular.sim,
	[highlight #CC0000]substring(cellular.ptn,1,3) + '-' + substring(cellular.ptn,4,3) + '-' + substring(cellular.ptn,7,4) as PTN,[/highlight]
	cellular.account,
	isnull(icitem_prodline.prodline,space(10)) as ProdLine,
	cellular.actdate ,
	isnull(ActType.Acttype,space(20)) as ActType,
	cellular.item,
	Cellular.MRC,
	isnull(ezposusers.username,space(20)) as Username 
from cellular 
	left outer join CellCust 
		on Cellular.fk_CellCust = CellCust.IID 
	left outer join ezposusers 
		on cellular.fk_ezposusers = ezposusers.iid 
			and cellular.fk_store = ezposusers.fk_store
	left outer join acttype 
		on cellular.fk_activationtype = acttype.iid 
	left outer join icitem_prodline 
		on cellular.fk_icitem_prodline = icitem_prodline.iid 
			and cellular.fk_store = icitem_prodline.fk_store 
	where cellular.fk_store = 7
		and (
		Cellular.Serial like @tcKeyword
		or Cellular.SIM like @tcKeyword
		or Cellular.Account like @tcKeyword
		or Cellular.PTN like @tcKeyword
		)
	order by custno,ptn,serial,actdate

Ez Logic
Michigan
 
When you have something like "###-###-###" in Input mask put also an [R] (w/o brackets) into Format property.
That way your chars wouldn't be eaten :)

Borislav Borissov
VFP9 SP2, SQL Server
 
This is something like:
Code:
? TRANSFORM("1234567890", "@R ###-###-####")


Borislav Borissov
VFP9 SP2, SQL Server
 
Pefect Brislav!

worked like a charmed..

saved me from changing a lot of my sql server's stored procedure, to change the phone to substring it and stuff it.

Ez Logic
Michigan
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top