View Single Post
  #5   Report Post  
Posted to microsoft.public.excel.programming
patrick molloy patrick molloy is offline
external usenet poster
 
Posts: 391
Default Pre-numbered forms, I think its impossible, but...

I find that saving the master file down each time
the "autonumber" increments is a poor idea. I tend to use
a number of methods.
The hardest is to use a SQL database where key data is
located and where each time I generate an invoice,
details get placed in a table - the table iD is used as
my autonumber. This is a great way to track stuff too.
Another method that I have used is simply to place a text
file in a "well known" location - say a folder on a
network, so that it can be quickly read and written to by
any excel workbook. This is great for where there are a
number of people that may generate invoices from a given
template. The risk of a collision is quite minute since
writing a number to a text file or reading it, is
blindingly fast!



Option Explicit

Const csINVOICEFILE As String _
= "C:\Temp\InvoiceNumber.txt"

Private Sub cmdNewNumber_Click()
' reads current number
'increments it
' saves it
Dim ff As Long
Dim Invoice As Long

ff = FreeFile
Open csINVOICEFILE For Input As ff
Input #ff, Invoice
Close ff

Invoice = Invoice + 1
lblInvoiceNumber.Caption = Invoice

ff = FreeFile
Open csINVOICEFILE For Output As ff
Print #ff, Invoice
Close

End Sub

Patrick Molloy
Microsoft Excel MVP
-----Original Message-----
Does anyone know how to set up a 'master' form that is

pre-numbered, or auto advances with every use. Example:
As the form is used, it is printed as form number 1000,
next use 1001, 1002 and so on. Need it to automatically
number it to avoid human error.

Currently using the form on one sheet, with a log on

another. Have tried using macro's, functions, etc. Can't
seem to find the right combo. All templates I have seen
do not have auto numbering, so I have a feeling it is
beyond excel's capabilities, but just in case I missed
something (new to excel, former Lotus user, new job).

Using Excel 2002.

Thanks for your thoughts and/or ideas.
.