conditional

  • Thread starter Thread starter Tcs
  • Start date Start date
T

Tcs

I have several fields that I wish to format, but only if there is data there TO
format. Here's one example:

Left([OLBPHN],3)+"-"+Right([OLBPHN],4)

It's for a phone number. The number is stored as a 7 digit number, but if
there's actually a number there (the value is greater than zero), I want to
insert the hyphen.

CAN I do this with SQL? If so, how? I've tried entering what I THINK is the
solution into the Query Builder grid, but all I get is a 'missing operator'
error. My books are providing NO help. Can you?

Thanks in advance.
 
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Try the Format() function in the SELECT clause (if using Access/JET db).
Debug window:

? format(9991235555,"(###) ###-####")
(999) 123-5555

--
MGFoster:::mgf00 <at> earthlink <decimal-point> net
Oakland, CA (USA)

-----BEGIN PGP SIGNATURE-----
Version: PGP for Personal Privacy 5.0
Charset: noconv

iQA/AwUBQS4oBoechKqOuFEgEQLEFACeMKInL3ldgs6ZdCncL+q/sJoTOD4AmQFm
s7aCaQ7XSzfzTiLT509IoVmB
=5yF2
-----END PGP SIGNATURE-----
 
Back
Top