"Sondra" <(E-Mail Removed)> wrote in message
news:721DC322-CF3E-43BC-A839-(E-Mail Removed)...
> Using Access 2002
>
> I have created the following to use in a WordMerge Document:
>
> Private Sub Form_Close()
> DoCmd.DeleteObject acTable, "tbl_DSCRMERGE"
> DoCmd.OpenQuery "qry_DSCRForm_RUN", acViewNormal
> DoCmd.OpenForm "DSCR_frm"
> End Sub
>
> However, I want to add a line to have a field in the Table formatted so
> that
> the number:
>
> 83175 shows as 08D-3175
>
> I know that if I go into the table after this is run each time I can do
> this; however, is there a way to add that to the above programming so that
> it
> automatically does it before the User closes the database.
>
> I'm very novice and write very "easy" processes. Any help would be great.
Am I right in concluding that qry_DSCRForm_RUN is make-table query that
creates the table tbl_DSCRMERGE? I'll continue based on that assumption.
Do you need the field's original number value to be preserved, in the output
table, but just formatted so that it appears the way you describe? Or would
it be okay if it is converted into a text field with actual values like
"08D-03175"?
If the latter is the case, then you could do your formatting in the query to
create a calculated field. Suppose, for example you have input table
"tbl_Input", with fields "ID" and "MyNumber", and it's the MyNumber field
that you want to be formatted in the output table. Then your make-table
query might look like this:
SELECT
tbl_Input.ID,
Format(tbl_Input.MyNumber,"00D-0000") AS MyNumber
INTO tbl_DSCRMERGE
FROM tbl_Input;
That's only an example, and I don't know for sure if that format expression
will work for all the values in your source data.
--
Dirk Goldgar, MS Access MVP
www.datagnostics.com
(please reply to the newsgroup)