By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,827 Members | 2,277 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,827 IT Pros & Developers. It's quick & easy.

How to autofill combobox with autonumber

P: 1
Hello, i am very new in access. The situation is like this. I have three company. Before this each company have their own customers database. But now I want to combine all the database from three company in one form. How I differentiate the customer is based on the service number. For example, if the service number start with number 6xxx that mean the customer is from Company A but if the service number is start with number 4xxx that means that the customer is from Company B. The Question is can i make an autofill service number in one form such as when I choose Company A automatic the service number will start with number 6xxx but if I choose Company B, the the service number will automatically change to number 4xxx
Dec 14 '16 #1
Share this Question
Share on Google+
1 Reply

Expert 100+
P: 1,107
This thread has quite a few different examples of similar solutions:
Format autonumber field properties to include 2 digit year

For you, I would build a function that takes the Company as a parameter and returns the next sequence number. You can then do one of the following:
  • Have your Default property for your Key field use the function and get the next key. You may need to .refresh the field to get it to re-determine the next key if you change the Company.
  • You can call the function from VBA in the AfterUpdate event of the Company field, so that the key value gets updated when the Company changes.
  • You can put some code in the Form_BeforeUpdate event to call the Function if needed and populate your Key field.
Dec 14 '16 #2

Post your reply

Sign in to post your reply or Sign up for a free account.