Jim,
This is a Select query, not an Update query, correct?
If you are using the QBE grid, you already have a SSN and a Pat_ID column.
In the next empty column, on the top Field line, write:
DashSSN:Left([SSN], 3) & "-" & Mid([SSN], 4, 2) & "-" & Right([SSN], 4)
I would also suggest you write:
Is Not Null
in the SSN criteria line to avoid an #Error if that SSN field is null.
When done, click on the View Tool button and select SQL view.
The query should read like this:
SELECT CDS.SSN, CDS.PAT_ID, Left([SSN], 3) & "-" & Mid([SSN], 4, 2) & "-" &
Right([SSN], 4) as DashSSN
FROM CDS
Where SSN is not null;
Click the Bang (!) tool button to run the query.
SSN Pat_ID DashSSN
123456789 101 123-45-6789
Note: You do not need to have the SSN field column in the query
unless you just want to compare the changes made.
SELECT CDS.PAT_ID, Left([SSN], 3) & "-" & Mid([SSN], 4, 2) & "-" &
Right([SSN], 4) as DashSSN
FROM CDS
Where SSN is not null;
Will work just as well.
Pat_ID DashSSN
101 123-45-6789
I hope you've got it now.
--
Fred
Please reply only to this newsgroup.
I do not reply to personal e-mail.
Jim said:
"Fredg" <fgutkind@att.net> wrote in message
Jim,
That's fine.
Just use the expression in a Select Query.
Fred and Ken,
I'm sorry to be such a bother, I'm not a total Access novice, but with
this one I'm over my head. Here's what I've done:
1. Create a query that selects all of my records from the table with
fields, SSN, and PAT_ID
2. My SQL statement looks like this
SELECT CDS.SSN, CDS.PAT_ID
FROM CDS;
I'm not sure where I should put the expression-- Left([SSN], 3) & "-"
& Mid([SSN], 4, 2) & "-" & Right([SSN], 4)--in the SQL statement.
Also, can I put this expression in the Criteria line of the SSN field
in the query? I tried Ken's update query suggestion, but the query
kept asking me for "Field to Update to."
I hate asking for such hand holding,
TIA,
Jim
DashSSN: Left([SSN], 3) & "-" & Mid([SSN], 4, 2) & "-" & Right([SSN],
4)
works better in here in the West. <g>
Jim,
To convert all the existing SSN's to include the hyphens, run an update
query.
After you update your table, then change your Input Mask so that
future entries will be saved with the mask.
Use:
000\-00\-0000;0;_
as the input mask. See Access Help.
--
Fred
Please reply only to this newsgroup.
I do not reply to personal e-mail.
Assuming that you're using a query as the basis of the report, add a
calculated field to the query that converts the stored SSN to one with
dashes:
DashSSN: Left([SSN], 2) & "-" & Mid([SSN], 3, 3) & "-" &
Right([SSN],
4)
Then use the DashSSN field in your report where you wish to
display
the
SSN.
--
Ken Snell
<MS ACCESS MVP>
Greetings all,
I need to convert a field that has social security numbers stored as
XXXXXXXXX to XX-XXX-XXXX. When I use the Input mask, the "-" are
present when the table is displayed, however, when I use this
table
in
creating a report using Crystal Reports, my string is back to
XXXXXXXX.
I can manually put the "-" in the fields, and it works, but I was
hoping for a less labor intensive way.
Thanks,
Jim