473,408 Members | 1,968 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,408 software developers and data experts.

Alternative to using Autonumber

12
I would like to know the code to use in an Access form that would be an alternative to using autonumber. My source table is called tblHelp Desk Tickets and my number table is called tblNextNum. The field I am using to for the next number to be pulled from is NextNumber. The control box on the form is called Helpdesk Ticket No, txtHelpdesk Ticket No.

Would apprecaite any help in this area, I am not that familiar with creating codes. Would also like the ticket number to pop in when I click on the create ticket button, so I don't know where within the code screen to even put this information.

Thanks so much,
Johnny
Jan 4 '07 #1
13 2993
Killer42
8,435 Expert 8TB
I would like to know the code to use in an Access form that would be an alternative to using autonumber. My source table is called tblHelp Desk Tickets and my number table is called tblNextNum. The field I am using to for the next number to be pulled from is NextNumber. The control box on the form is called Helpdesk Ticket No, txtHelpdesk Ticket No.

Would apprecaite any help in this area, I am not that familiar with creating codes. Would also like the ticket number to pop in when I click on the create ticket button, so I don't know where within the code screen to even put this information.
You should be able to create a public function which returns the next number and updates tblNextNum. Then depending on how your form works, maybe one of the following:
  • In the click event for the create button, assign the value returned by your function to the ticket number control.
  • Do something similar in the forms Before Insert or After Insert event.
  • Maybe just set the function name as the default value for the ticket number field in [tblHelp Desk Tickets]. If it achieves what you want, this is probably the simplest.
Jan 4 '07 #2
NeoPa
32,556 Expert Mod 16PB
You haven't really said exactly how you want it to work.
Do you want to reuse any number that gets finished with?
Do you just want to keep counting upwards infinitely?
The answer would depend on the answer to this question.
Jan 7 '07 #3
Killer42
8,435 Expert 8TB
You haven't really said exactly how you want it to work.
Do you want to reuse any number that gets finished with?
Do you just want to keep counting upwards infinitely?
The answer would depend on the answer to this question.
True. also, something I forgot to mention. Not sure how important it will be in the Access environment, but any public function which does the number-generation stuff I mentioned, should do it in a separate transaction. In other words, it should BeginTrans, generate/update the next-number value, then CommitTrans. And this part of the process should be done as quickly as possible, to reduce contention for the control record.
Jan 8 '07 #4
jlf
12
You haven't really said exactly how you want it to work.
Do you want to reuse any number that gets finished with?
Do you just want to keep counting upwards infinitely?
The answer would depend on the answer to this question.

I want a unique number every time I want to create a new ticket. No number will be reused. A good example of what I am trying to do would be when someone creates a new purchase order request and it gets assigned a unique purchase order number. I just want an automatic number to pop into the helpdesk ticket control box. Hope this helps.
Jan 8 '07 #5
jlf
12
True. also, something I forgot to mention. Not sure how important it will be in the Access environment, but any public function which does the number-generation stuff I mentioned, should do it in a separate transaction. In other words, it should BeginTrans, generate/update the next-number value, then CommitTrans. And this part of the process should be done as quickly as possible, to reduce contention for the control record.

I apologize, but I am a complete newbie, so not really following along on your suggestion.
Jan 8 '07 #6
jlf
12
Thanks for your help, but I got it working.
Jan 8 '07 #7
NeoPa
32,556 Expert Mod 16PB
It should not be necessary to store the numbers separately in a table.
We can get the next number by simply looking at the numbers already in use and adding one to the highest found.
Assuming your command button is called cmdNewTicket and the field in your table [tblHelp Desk Tickets] is called [Ticket No] :
Expand|Select|Wrap|Line Numbers
  1. Private Sub cmdNewTicket_OnClick()
  2.     [txtHelpdesk Ticket No] = DMax("[Ticket No]", "[tblHelp Desk Tickets]") + 1
  3. End Sub
Jan 8 '07 #8
Killer42
8,435 Expert 8TB
It should not be necessary to store the numbers separately in a table.
We can get the next number by simply looking at the numbers already in use and adding one to the highest found.
...
Well yes, but that sort of assumes a single user.

In a multi-user setup, this would only work if you can somehow ensure no overlap. For instance, assign the number and immediately store your record containing it, so that the next person using the DMax will see yours. Even then, to be really sure, you'd have to check again after storing the record, to ensure you didn't create a duplicate.

Seems to me, a separate "assigned numbers" table would allow more reliability, with less work.
Jan 8 '07 #9
Killer42
8,435 Expert 8TB
I apologize, but I am a complete newbie, so not really following along on your suggestion.
Don't worry too much. I suppose the situation can be dealt with, if and when it occurs.

However, I did have one question for you. Why can't you just use an AutoNumber?
Jan 8 '07 #10
jlf
12
I did exactly what Neopa suggested and it is working fine. This is not a multiuser environment. I chose this method because of past experiences with autonumber and this also gives us the option to assign a year to each ticket and not starting diirectly with 1, we are starting with 20070001. This is per request of management, but thank you again for your assistance.
Jan 8 '07 #11
NeoPa
32,556 Expert Mod 16PB
Post #9
Killer,
Would you really want to take someone through those complexities on a web site. Your courage and fortitude amaze and impress me ;)
Jan 8 '07 #12
Killer42
8,435 Expert 8TB
Killer,
Would you really want to take someone through those complexities on a web site. Your courage and fortitude amaze and impress me ;)
Of course not - that's what we have Access experts for. :D
Jan 8 '07 #13
NeoPa
32,556 Expert Mod 16PB
Killer,
Would you really want to take someone through those complexities on a web site. Your courage and fortitude amaze and impress me ;)
Of course not - that's what we have Access experts for. :D
Oops - I feel I've just been hit for six.
Jan 8 '07 #14

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

Similar topics

2
by: Smriti Dev | last post by:
Hi, I wanted to know what I can use to increment a number in MS ACESS 2000 for a number field instead of using autonumber. Thanks for your help. smriti
1
by: Simeon Nevel | last post by:
As a personal exercise, I'm trying to create a call tracking DB for my own use at work. Here's an abbreviated version of the database layout: Company: CompanyID - Primary Key (Text Length...
5
by: Ilan Sebba | last post by:
When it comes to adding records in related tables, Access is really smart. But when I try to do the same using ADO, I am really stupid. Say I have two parent tables (eg Course, Student) and one...
33
by: Lee C. | last post by:
I'm finding this to be extremely difficult to set up. I understand that Access won't manage the primary key and the cascade updates for a table. Fine. I tried changing the PK type to number and...
1
by: BT Openworld | last post by:
I've just had to upgrade to Access 2003. Our company's main sales database started in Access V1.0 and has progressed through V2.0 and 97 without problems. I've converted it to 2003 format and have...
35
by: Traci | last post by:
If I have a table with an autonumber primary key and 100 records and I delete the last 50 records, the next record added would have a primary key of 101. Is there any way to have the primary key...
1
by: John Phelan-Cummings | last post by:
I'm not certain if this made the post. Sorry if it's a repeat: Using a Button to take an autonumber from one form to populate another autonumber field on another form. I have a Mainform "A"...
4
by: Rico | last post by:
Hello, I'd like to change a field from an Autonum to a Long data type using DAO. I knwo how to set the attribute, but don't know how to remove it. Any ideas? Thanks!
10
by: MLH | last post by:
Suppose, in a multi-user environment, you have append query SQL in a VBA procedure that looks like INSERT INTO MyTable... and the next line reads MyVar=DMax("","MyTable... You can never be...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.