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 gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Autonumber format

Status
Not open for further replies.

miltie

Technical User
Nov 4, 2002
15
US
Good morning all,

I have a question concerning an autonumber field. Each record is autonumbered with the format \70"IW-"0"3-"000. Each record is numbered as 70IW-03-001, 70IW-03-002, etc. This works fine when the record is input in an access report or an .rtf file, but I have the report opening as a Word doc. The result shows 01, 02, etc, not the 70IW-03-001, 70IW-03-002 format I need.

Any help would be greatly appreciated.

Thanks,
Milt

 
i dont know how you are createing your autonumber try adding
the format function format(lastthreedigets,"000")
 
I knew the format of my autonumber maybe a problem, but it worked fine and still is. I just needed to transfer the number to a word document, that's when it became a problem. I just really need the number formatted as 70IW-03-001, etc.

Here's my code for transfering it to a word doc.

Sub PrintSSSWithWord()
Dim objWord As Word.Application

Dim strSQL As String
Dim frmSSS As Form_frmSSS

Set objWord = New Word.Application
objWord.Documents.Add _
Application.CurrentProject.Path & "\SSS.dot"
objWord.Visible = True

With objWord.ActiveDocument.Bookmarks
.Item("ActionOfficer").Range.Text = Form_frmSSS.ActionOfficer
.Item("OfficeSymbol").Range.Text = Form_frmSSS.OfficeSymbol
.Item("PhoneNumber").Range.Text = Form_frmSSS.PhoneNumber
.Item("ControlNumber").Range.Text = Form_frmSSS.ControlNumber

Set objWord = Nothing
End With
End Sub

ControlNumber is my autonumber field. Is there a way to code it to the format I need? Or do I need to make a global declaration? Or am I just missing the boat?

Thanks,
Milt
 
i am supriesed that .Item("ControlNumber").Range.Text= form_frmSSS.ControlNumber returns 70IW-03-2 when in the form it is formated as 70IW-03-002
try .Item("ControlNumber").Range.Text= str(form_frmSSS.ControlNumber)

or .Item("ControlNumber").Range.Text= left(form_frmSSS.ControlNumber,8)& format(mid(form_frmSSS.ControlNumber,9,3),"000")
 
This bit of data should be broken up into (at least) four fields. You're storing compound data in a single field and that's just a bad habbit. Split it up. When you need to display it, concatenate. But there's no real reason to store all of this in one field, unless it's coming electronically from some other source that you can't alter.

Jeremy =============
Jeremy Wallace
Designing, Developing, and Deploying Access Databases Since 1995

Take a look at the Developers' section of the site for some helpful fundamentals.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top