Hi,
Can someone help me how I can create alphanumeric auto id in my form?
Hi,
Can someone help me how I can create alphanumeric auto id in my form?
What are the rules?
Why does it need to be alpanumeric?
Will Autonumber not work for your situation?
You can generate an Alpha/Numeric auto-incrementing 'number,' but as has been said, we really need to know what your exact requirements are, in order to help you.
Also, is this a multi-user environment?
Linq ;0)>
The problem with making anything foolproof...is that fools are so darn ingenious!
All posts/responses based on Access 2003/2007
I Just need the method how to generate
The reason we are asking about your "need for an alphanumeric auto increasing number" is because an autonumber should have no meaning to you. An autonumber serves to assign a unique number to each record in your table only - Not necessarily incremental/sequential; not necessarily positive.
see Graham Seach's article here http://www.office-archive.com/41-ms-...5e4f31bab5.htm
What orange has said is very true, if your only purpose for this 'Alpha Numeric auto id' is to act as a unique Record identifier. If this is the purpose, here, you should use an Autonumber, generated automatically by Access, and there is no reason for this to be Alpha Numeric, as it should never be seen by human eyes! If you're trying to do something else, here, such as generate a customer number, account number, etc., that's another story altogether.
Assuming you're talking about the latter scenario, as I said before, you can generate an Alpha/Numeric auto-incrementing 'number.' But how you go about this, as also said before, depends on your requirements!
Do you only want to increment the Numeric portion?
Is the Alpha portion always the same, or does it change, as well?
If Yes to #2, when/why does the Alpha portion change?
If Yes to #2, is the Numeric portion reset to one when the Alpha portion changes?
Things like that! A general method, for simply increasing a 'numbers only' ID number, would be
Code:Private Sub Form_BeforeUpdate(Cancel As Integer) If Me.NewRecord Then Me.ID = Nz(DMax("[ID_Field]", "YourTableName") + 1, 1) End If End Sub
If above would be used in a multi-user environment, because you need to assign the number at the last possible moment, to decrease the chance of two users getting the same generated number. If this is intended for a single-user environment, you can put the same code in the Form_Current event.
Linq ;0)>
The problem with making anything foolproof...is that fools are so darn ingenious!
All posts/responses based on Access 2003/2007
Thank you very much. Now it is clear to me.
Plz Explain this Portion in detail.thanks
===
As for starting the Autonumber at 10,000, use the following procedure:
1. In table design view, (if the Autonumber field is the primary key),
remove the primary key designator.
2. Change the Autonumber field to a Number (Long Integer).
3. Save the table.
4. Create an insert query to create a new record in the target table.
INSERT tblMyTable (PrimaryKeyField, SomeOtherField) VALUES (9999, "other
value")
'This will insert a record whose Autonumber field = 9999.
5. View the data in the table, and delete the record you added in Step 4.
6. Open the table in design view, and restore the field to an Autonumber
data type.
7. Also restore the primary key designator.
The next record added to this table will be 10,000. Just make sure you don't
compact the database before entering a new record into this table, otherwise
the Autonumber field will be reset.==