Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Autonumber a field, but not the usual way

Status
Not open for further replies.

Acipenser

Technical User
Oct 15, 2001
39
US
I need to be able to autonumber a field, but simply using the autonumber type wont work. Here is why:

Currently the user enters the quantity of straws to be entered into the database, and access assigns these individual straws a number, consequetively from the last number entered. For example, the last straw entered is 25. A new user enters 5 straws. They will be assigned 26-30, and saved as individual records (I need to know information for each straw).

What I would like for access to do is:
The user will enter the number of the first straw and the quantity, and access will assign each straw a number starting with the one entered by the user. I would also like access to check to see if any of these numbers are already in the database, and disallow the entry of duplicate numbers. Make the user enter a new series of numbers.

How do I do this?

Thanks
 
Use VBA:
Use recordsets and the following methods and properties
findfirst
nomatch
Addnew
update

You'll also probably use Dmin to find the smallest number that is bigger than you start value and test (if ... then) if it is in the range to be created before adding the new records (addnew and update).
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top