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

Sequential numbering using 'on click'

Status
Not open for further replies.

JustMaybe

Technical User
Oct 18, 2002
5
0
0
GB
Hi have a massive problem i just can't solve!!!

I have a form 'orders' that has a number of reports that are generated from it. One of these reports needs a unique number assigned to it.

This report is not necessarily generatde for each record. this means that i cannot use a 'autonumber' or a PK as the number would not be sequential.
For some mad idea each time an invoice is generated a number must be generated. (for analysis reasons) and not one number can be redundant.

I intially approched this problem and realised that i would need some code in the 'on click' detail buton used to generate this report.

I have begun...but this code simply won't work
Am i even on the right track?
Private Sub PI_Click()
On Error GoTo Err_PI_Click

Dim stDocName As String

Me.InvoiceNo = Me.InvoiceNo + 1

stDocName = "Invoice"
DoCmd.OpenReport stDocName, acPreview

Exit_PI_Click:
Exit Sub

Err_PI_Click:
MsgBox Err.Description
Resume Exit_PI_Click

End Sub


I have made a field in my table called 'invoice no.' as i need a record stored of this number in relation to the record it is stored as.

Any help or suggestions would be massively appreciated. Thank you
Sarah
 
HI

It is not a good idea to generate the number in the Invoice Report, - what happens if you need to reprint the invoice?, eg becuase the copy is lost, or the paper jams etc

You need to create an Invoice Record, in a table, assign a unique number, and use that number in your report.

There have been at least two postings today on the subject of generating unique numbers

Hope this helps Regards

Ken Reay
Freelance Solutions Developer
Boldon Information Systems Ltd
Website needs upgrading, but for now - UK
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top