Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / New Users / January 2008

Tip: Looking for answers? Try searching our database.

how to do sequential numbering for Purchase Order in Access 2003

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
carau - 07 Jan 2008 22:09 GMT
Im useing Office Professional 2003 and the access database program and am
trying to create my own Purchase Order database/form. I need to also be able
to print each Purchase Order from time to time. I would like it to
automatically assign each PO its own number each time a PO is written,
however each PO must began with the same 3 digits every time. (example:
240-###1 then the next would be 240-###2 and so on)
Jeanette Cunningham - 08 Jan 2008 00:46 GMT
Hi,
Have a separate table with one field only that is a long integer and one
record only.
Each time you want to create the PO number, you create the number by using
240-### and concatenating it with the next highest number from that table.
You use a DLookup on that table to get the last used number, then add 1 to
it to get the number you need.
When you have finished and saved that PO number in your form, then you will
update that table and set its one and only record to the number you just
used.
Next time you do the DLookup on that table, you will see that last number
used and can just add 1 to it.

Jeanette Cunningham

> Im useing Office Professional 2003 and the access database program and am
> trying to create my own Purchase Order database/form. I need to also be
[quoted text clipped - 3 lines]
> however each PO must began with the same 3 digits every time. (example:
> 240-###1 then the next would be 240-###2 and so on)
Dale Fye - 08 Jan 2008 18:43 GMT
If every PO contains the "240-", then I would just drop that from the data,
and display it as part of the label for the PO.  Then, you could just use an
autonumber field for your actual PO number field.

If, however, the prefix of your PO numbers change based on the year or some
other value, then, I would recommend two fields.  One to track the prefix and
another for the suffix.  If you do it this way, then I would make my PO#
field a long integer (rather than an autonumber) and use a technique similar
to that described by Jeanette to get the value of that field each time you
create a new PO.

HTH
Dale
Signature

Don''t forget to rate the post if it was helpful!

email address is invalid
Please reply to newsgroup only.

> Im useing Office Professional 2003 and the access database program and am
> trying to create my own Purchase Order database/form. I need to also be able
> to print each Purchase Order from time to time. I would like it to
> automatically assign each PO its own number each time a PO is written,
> however each PO must began with the same 3 digits every time. (example:
> 240-###1 then the next would be 240-###2 and so on)
BruceM - 08 Jan 2008 21:35 GMT
I would avoid autonumber for this, since it will almost invariably create
gaps in the numbering.  One way to simulate an autonumber, but without gaps,
is shown here:
http://www.rogersaccesslibrary.com/download3.asp?SampleName=AutonumberProblem.mdb
There are other options, such as VBA, using the principle outlined in the
example.
If the 240 is constant, I agree with the response that suggested
concatenating the number as needed.  If the 240 is changeable, you will need
to state the rule by which it changes.

> Im useing Office Professional 2003 and the access database program and am
> trying to create my own Purchase Order database/form. I need to also be
[quoted text clipped - 3 lines]
> however each PO must began with the same 3 digits every time. (example:
> 240-###1 then the next would be 240-###2 and so on)
Arvin Meyer [MVP] - 09 Jan 2008 04:23 GMT
> Im useing Office Professional 2003 and the access database program and am
> trying to create my own Purchase Order database/form. I need to also be
[quoted text clipped - 3 lines]
> however each PO must began with the same 3 digits every time. (example:
> 240-###1 then the next would be 240-###2 and so on)

The following code will look at the value in your table then add 1 to the
maximum value. The PO Number is a real number but it's formatted the way you
want in the form. In the printed PO, you'll need to either use the value in
the form, or recreate the formatting from the underlying PO number.

Function GetPO() As Long
On Error GoTo Error_Handler

Dim rstID As DAO.Recordset
Dim lngMaxID As Long
Dim db As DAO.Database

Set db = CurrentDb

   Set rstID = db.OpenRecordset("Select Max(PONumber) As MaxID FROM tblPO")
   If IsNull(rstID!MaxID) Then
       'no records yet, start with one
       lngMaxID = 1
   Else
       lngMaxID = rstID!MaxID + 1
   End If

   GetPO = lngMaxID

   Me.txtPONumber = "240-" & Format(lngMaxID, "0000")

Exit_Here:
   rstID.Close
   Set rstID = Nothing
   Set db = Nothing
   Exit Function

Error_Handler:
   MsgBox Err.Number & ": " & Err.Description
   Resume Exit_Here

End Function
Signature

Arvin Meyer, MCP, MVP
http://www.datastrat.com
http://www.mvps.org/access
http://www.accessmvp.com

 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.