Auto Purchase Order Number

  • Thread starter Thread starter Gary.
  • Start date Start date
G

Gary.

I need to be able to set up a form to enter Purchase Orders.
I would like to have a auto purchase order number.

Thanks
 
On Mon, 11 May 2009 06:38:01 -0700, "Gary." <[email protected]>
wrote:

You can use an Autonumber field in the underlying table. Or in the
Form_BeforeInsert you can write some VBA code to construct a number on
the fly. What code? Depends on your requirements for the PO number.

-Tom.
Microsoft Access MVP
 
You can use an Autonumber field in the underlying table. Or in the
Form_BeforeInsert you can write some VBA code to construct a number on
the fly. What code? Depends on your requirements for the PO number.

-Tom.
Microsoft Access MVP

Tom thanks for you reply

I just need to be able to incress a number by one
 
Then you can use an AutoNumber, or the "DMax() + 1" technique.

-Tom.
Microsoft Access MVP
 
I need to be able to set up a form to enter Purchase Orders.
I would like to have a auto purchase order number.

Thanks

Put the following code (adapted to your database, of course I don't know your
table or fieldnames) in the BeforeInsert event of your form:

Private Sub Form_BeforeInsert(Cancel as Integer)
Me!PONumber = NZ(DMax("[PONumber]", "[Purchaseorders]")) + 1
End Sub

This will work for a one-user system but could lead to problems if it's a
shared multiuser database (two users could get the same ID if they both have
the form open at the same time). Post back if that's an issue.
 
I need to be able to set up a form to enter Purchase Orders.
I would like to have a auto purchase order number.

Thanks

Put the following code (adapted to your database, of course I don't
know your table or fieldnames) in the BeforeInsert event of your form:

Private Sub Form_BeforeInsert(Cancel as Integer)
Me!PONumber = NZ(DMax("[PONumber]", "[Purchaseorders]")) + 1
End Sub

This will work for a one-user system but could lead to problems if
it's a shared multiuser database (two users could get the same ID if
they both have the form open at the same time). Post back if that's an
issue.

John Their will be times the more than one person maybe entering PO's what
would you suggest

thanks for your help
Gary
 
I need to be able to set up a form to enter Purchase Orders.
I would like to have a auto purchase order number.

Thanks

Put the following code (adapted to your database, of course I don't
know your table or fieldnames) in the BeforeInsert event of your form:

Private Sub Form_BeforeInsert(Cancel as Integer)
Me!PONumber = NZ(DMax("[PONumber]", "[Purchaseorders]")) + 1
End Sub

This will work for a one-user system but could lead to problems if
it's a shared multiuser database (two users could get the same ID if
they both have the form open at the same time). Post back if that's an
issue.

John Their will be times the more than one person maybe entering PO's what
would you suggest

A few options, of increasing complexity:

1. If there are no required fields other than the PONumber, put a line

Me.Dirty = False

right after the Me!PONumber line to immediately save the record.

2. If it's not necessary for the user to see the PONumber as they're entering
data move the line from the BeforeInsert event to the BeforeUpdate event. It
will be assigned the instant before the record is saved to disk.

3. Do a search for "Access Custom Counter" VBA code. I use (copyrighted) code
from the Access Developers' Handbook by Getz et al., so I'm reluctant to post
it here.
 
Back
Top