Access 2010 & Alpha-Numeric Issue (1 Viewer)

gerryp

Registered User.
Local time
Today, 13:31
Joined
May 10, 2007
Messages
32
A total noob so I am when it comes to MS Access - self thought so apologies in advance.

I’m creating an Access 2010 database to record Purchase Orders.

I want each unique PO number to be Alphanumeric, to begin with “IT” and to automatically increment e.g. “IT000001”, then "IT000002" etc etc

How is this best done ?
 

gerryp

Registered User.
Local time
Today, 13:31
Joined
May 10, 2007
Messages
32
I think I may have found a solution, but it may not be THE correction solution ???

Apparently the attached should work ??
 

Attachments

  • Add prefix to Autonumber.png
    Add prefix to Autonumber.png
    46.1 KB · Views: 77

Anakardian

Registered User.
Local time
Today, 14:31
Joined
Mar 14, 2010
Messages
173
Doing that will ensure you have a unique number.

The number may or may not be sequential and can be both positive and negative.

I would certainly use the autonumber but only as a reference internally in the database.
To have something that can be referenced by a human I would create my own numbering scheme.
In your case I may add two columns with one containing the number and the other the prefix.
That way I can have different prefixes in use at the same time.

As for making a number, I would use MAX to find the highest number used and add 1.
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 20:31
Joined
May 7, 2009
Messages
19,233
on your Form's beforeInsert event, set the PO Number textbox:

Private Sub Form_BeforeInsert(Cancel As Integer)
Dim vRet As Variant
vRet = Nz(DMax("PoNumber", "POTable"), 1)
If Not IsNumeric(vRet) Then
vRet = Val(Right(vRet, Len(vRet)-2)) + 1
End If
Me.PoNumber = "IT" & Format(vRet, "000000")
End Sub
 

Users who are viewing this thread

Top Bottom