VB Get ID Routine





techstore
LQ Net Home







GetID Utility

Print Version    Printer Friendly Version


Instead of using an auto-number in a database, you can assign numbers yourself with VBA code. There are several advantages to this: To use this function, create a table called "tblDefaults". This is where the starting numbers are stored.

Create a record for each table that needs a unique number key.

Customer 100
Order 1001
Invoice 25000
Inventory 10


In the above table, there is a specific starting number for each type of information. Customers are to be started from number 100. Invoice numbers will start from number 25000.

In your VBA code, when you need a new ID number, call this function with the name of the item to be numbered.
newOrderNumber = getID "ORDER"

Here is the code for the getID function
After calling the getID function, newOrderNumber will contain the value 1001 and the value in the default table will be 1002



























Copyright © 2006-2009, LQ Systems,Inc. All rights reserved.