Google Groups no longer supports new Usenet posts or subscriptions. Historical content remains viewable.
Dismiss

Counters

1 view
Skip to first unread message

CiaraG

unread,
Aug 8, 2000, 3:00:00 AM8/8/00
to

I have a project where I want to assign a number to each transaction
automatically i.e once the first transaction is saved No. 2 will appear
within the transaction number box. Where should the coding actually be
placed?


Harald Staff

unread,
Aug 8, 2000, 3:00:00 AM8/8/00
to

Ciara

Here is some old code that should do the trick (the counter is saved on HD
as a microscopic text file):

Function TransacNumber() As Long
Dim Storage As String
Dim Storagefile As String

Storagefile = "C:\Egen\Nummer.num" 'the file

If Dir(Storagefile) = "" Then
TransacNumber = 0
Else
Open Storagefile For _
Input Access Read As #1
While Not EOF(1)
Line Input #1, Storage
TransacNumber = Val(Storage)
Wend
Close #1
End If
TransacNumber = TransacNumber + 1
Open Storagefile For _
Output Access Write As #1
Print #1, TransacNumber
Close #1
End Function

Sub test()
MsgBox "This is transaction number " & _
TransacNumber
End Sub

I can not tell you where to place it, because I don't really know when you
want to renumber and what happens before that... The thisworkbook
before_save will renumber /before/ saving, probably not a good idea.

Best wishes Harald

CiaraG <ciara.g...@uk.pwcglobal.com> skrev i
news:01c00138$4c905e60$3122...@UK679621.gbcoopers.com...

0 new messages