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!

Random number for invoice report 2

Status
Not open for further replies.

Zed5010

IS-IT--Management
Oct 9, 2005
42
CA
Hello,

I have designed an invoice report that needs to pick up a random and unique invoice number. say starting at 1000.

This number needs to remain in the report permanently. (i.e. even after re-opening the report).

Does each record belonging to the invoice need to be updated with the invoice#?

Any help would be much appreciated.
 

On the BeforeInsert-event you can put something like:

Private Sub Form_BeforeInsert(Cancel As Integer)
Me.InvoiceNo = 1000 + Int((100000 * Rnd) + 1)
End Sub

Pampers [afro]
There is only one way to change a diaper - fast
 
sorry, my code is for a form, not a report

Pampers [afro]
There is only one way to change a diaper - fast
 
But I think that putting it in the form where you compose the invoice, would be a better place to create the Invoice Number

Pampers [afro]
There is only one way to change a diaper - fast
 
How are ya Zed5010 . . .

[blue]If your tables & relationships are setup properly, this should'nt be necessary![/blue] . . . [purple]A PK (PrimaryKey) from the right table should suffice . . .[/purple]

Your thoughts! . . .

Calvin.gif
See Ya! . . . . . .
 
I have many records that will need the same invoice# stored permanently.

Once the invoice is printed, I need to reduce my inventory database level by the quantities in the invoice.

Any ideas?

Zed
 
I think you have to think more from forms instead of reports. Your form would be something like an order form, where quantities ordered and prices are entered for a customer. Here you can set an invoice number, and update your inventory. To give you some idea, you can use the Northwind sample database under the help-menu of Access.

Pampers [afro]
There is only one way to change a diaper - fast
 
Need to somehow append a randomly generated unique invoice# to a field in all records that match qry.

Thanks

Zed
 
Thanks Guys,

I just remembered that on every record there is an order form number, therefore I can use this # and append say "A" to get the invoice # xxxxxx-A

Cheers!

Zed
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top