I have a table for vendors. When we get a new vendor, the vendor number has not been assigned. I would like to find a way to assign a sequential number until we get the correct vendor number. How can I do this?
Thanks for any help.
itconc
![]() |
Patch reliability is unclear, but widespread attacks make patching prudent. Go ahead and patch, but watch out for potential problems. |
SIGN IN | Not a member? | REGISTER | PLUS MEMBERSHIP |
Home » Forums » AskWoody support » Productivity software by function » MS Access and database help » Need sequential numbers sometimes
I have a table for vendors. When we get a new vendor, the vendor number has not been assigned. I would like to find a way to assign a sequential number until we get the correct vendor number. How can I do this?
Thanks for any help.
itconc
The only thing I can think of is to have 2 fields. VendorID would be an autonumber and is the Primary Key of the vendor table. It is the field that links to the other tables. The users never see this field.
Another field would be “VendorNo” (or whatever). This is the field users will see. You can make anything in this field, even “Temp”, and then enter the correct # when you get it (I’m assuming it is assigned by some other department). Changing this VendorNo won’t affect anything. You don’t have to Cascade updates or anything like that.
Thanks to all of you.
I will think about Mark’s suggestion. We have to have access to the vendor number – it is assigned by our outsorced group in India.
I am not sure I like the autonumber. There is a tendency to enter the vendor number twice. Autonumbers would not take care of that issue.
However, I will think about this and might try it.
Thanks again.
Mark has the right idea, treat the “assigned” vendor number as just another data item like vendor name. Using an auto-increment field as the table primary key. That avoids a lot of problems if you have related records linked by a vendor number that will change when credit control have approved the vendor (or whatever triggers the assignment of the number). For most purposes you can hide the primary key field.
In Access forms the autoincrement number is assigned as soon as you enter something in the “new” record so there’s no problem creating linked records. In other cases you might need to re-read the record to retrieve the primary key. If you rarely enter vendors and the number is assigned quickly you could set a default value for the vendor number field and make the field a unique index. You can then easily find the newly created record from the default vendor number and retrieve it’s primary key value.
If you routinely add several vendors before getting an assigned vendor number you’ll need unique temporary vendor numbers. Following Browni’s suggestion, add some VBA to the “before insert” event on the form like
vendornumber = nz(dmax(“vendornumber”, “vendors”),0) + 1
That will have the effect of adding a sequential vendor number as you start to enter the new vendor details. (the nz() is just in case someone picks up this code and tries it on an empty table)
Ian.
Donations from Plus members keep this site going. You can identify the people who support AskWoody by the Plus badge on their avatars.
AskWoody Plus members not only get access to all of the contents of this site -- including Susan Bradley's frequently updated Patch Watch listing -- they also receive weekly AskWoody Plus Newsletters (formerly Windows Secrets Newsletter) and AskWoody Plus Alerts, emails when there are important breaking developments.
Welcome to our unique respite from the madness.
It's easy to post questions about Windows 11, Windows 10, Win8.1, Win7, Surface, Office, or browse through our Forums. Post anonymously or register for greater privileges. Keep it civil, please: Decorous Lounge rules strictly enforced. Questions? Contact Customer Support.
Want to Advertise in the free newsletter? How about a gift subscription in honor of a birthday? Send an email to sb@askwoody.com to ask how.
Mastodon profile for DefConPatch
Mastodon profile for AskWoody
Home • About • FAQ • Posts & Privacy • Forums • My Account
Register • Free Newsletter • Plus Membership • Gift Certificates • MS-DEFCON Alerts
Copyright ©2004-2025 by AskWoody Tech LLC. All Rights Reserved.
Notifications