473,386 Members | 1,733 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,386 software developers and data experts.

Sequential Numbers on Forms

22
I have a form "Job_Edit" with a subform. The subform called "JobTask" is a continuous form and includes a look-up combo box for a range of tasks. After I choose say 4 separate tasks, I can print a report in the correct order no problem because I inserted a text box with control source =1 and running sum in the report.

However, when I close the form and re-open it, the selected tasks have been re-ordered by their TaskID no. which of course is an autonumber. I have been exploring DMax and even manually entering a no in a text box next to each task and trying to use Order By.

Unfortunately this has all proved beyond me! Ideally, I would like the sort order to always be that in which the tasks were selected. Also ideally, if a new set of numbers is required, I would prefer these to be automatic. BUT they need to start at No.1 for each job in "Job_Edit".

Any help much appreciated.

Thank you
Mar 15 '08 #1
10 4112
Stewart Ross
2,545 Expert Mod 2GB
...However, when I close the form and re-open it, the selected tasks have been re-ordered by their TaskID no. which of course is an autonumber. I have been exploring DMax and even manually entering a no in a text box next to each task and trying to use Order By. ...
Hi. To avoid changing key field relationships for your tables - which would be a very bad thing to do if everything is otherwise working fine - the simplest thing I can think of which would resolve your difficulties for new records added is to add a new autonumber field called EntryOrder to the table which is the recordsource for your Job Task form. if Job Task is based on a query of the underlying table then all you need to do after adding the field is to include the new field in your query and sort on this field in ascending order.

If your Job Task table is not based on a query then create a new query, add all the fields of the Job Task table to the query (including the new EntryOrder field) and, as above, sort on this field in ascending order, then change the recordsource of your Job Entry form to the name of this new query.

A downside of this approach is that it may not do anything to overcome the current ordering of your existing records. It will ensure that all new job tasks are shown in entry order, regardless of whether the tasks are added all at once or in batches. The autonumber is really just providing a sequence number - it is not being used as any form of key field. The EntryOrder field will not necessarily be numbered in consecutive order (1, 2, 3 and so on), as new tasks may be added after adding other tasks for other jobs, but even so it will be sequentially numbered (1, 2, 7, 10, for instance). It is the sequential nature which will provide the ordering you seek without having to deal with incrementing a numeric counter field yourself.

-Stewart
Mar 15 '08 #2
Hulm1
22
Thanks very much for the reply. My table will not allow two autonumber fields, however. The primary key is the existing autonumber
Mar 15 '08 #3
Stewart Ross
2,545 Expert Mod 2GB
Thanks very much for the reply. My table will not allow two autonumber fields, however. The primary key is the existing autonumber
Hi. The fact that you already have an autonumber field, although somewhat of a surprise to me, should allow the ordering of your records by entry order as I described.

Are you ordering your query on this field? Is there anything else which identifies tasks? If there is, order by these other fields first, then have the ordering of the autonumber field last in your query. You should then see your records in job and entry sequence.

-Stewart
Mar 15 '08 #4
Hulm1
22
The subform is not based on a query, just the table. I will choose from the combo box a specific task and then in the next record below, choose another task. It may be that the first task I choose has TaskID (the autonumber) 12. However, the next task I choose may have TaskID 3. When I close the form and re-open it, the records have been re-ordered to show TaskID 3 first.

Obviously this is not the point at all! As I want to show the tasks in the order in which they were selected. They will change from job (Main Form) to job.

Does this help?

Could I be looking for some dynamic counter?
Mar 15 '08 #5
ADezii
8,834 Expert 8TB
The subform is not based on a query, just the table. I will choose from the combo box a specific task and then in the next record below, choose another task. It may be that the first task I choose has TaskID (the autonumber) 12. However, the next task I choose may have TaskID 3. When I close the form and re-open it, the records have been re-ordered to show TaskID 3 first.

Obviously this is not the point at all! As I want to show the tasks in the order in which they were selected. They will change from job (Main Form) to job.

Does this help?

Could I be looking for some dynamic counter?
  1. Try creating a Field named [Entered] {DATE/TIME} in your Table.
  2. Assign this Field the Default Value of Now() which contains a Time as well as Date element.
  3. Make the Record Source for your Sub-Form a Query containing the Table buit only now with the [Entered] Field as your Primary Sort (leftmost Field in Query Grid in Ascending Order).
  4. Due to the Time Component of Now(), your Records may sort correctly.
Mar 15 '08 #6
Stewart Ross
2,545 Expert Mod 2GB
Hi. The ordering you are getting is proving a problem because of your choice of key - tables based on autonumber keys will always be displayed in sequential order.

ADezii's suggestion of adding a date/time field is I reckon the best way to go in the circumstances.

As a piece of general advice it is usually better to define a query which includes all fields from the base table and base your form on the query, not the table. It allows much more scope for sorting records.

If you do add a date field as ADezii suggested, you will have to base your form on a query of your table, as you need to be able to change the ordering of records displayed from autonumber order to date order. You can't do this by basing the form directly on the table, because the primary key defines the default ordering of the table values, and with an Autonumber field as the key the table will always be shown ordered sequentially in autonumber order.

-Stewart
Mar 16 '08 #7
Hulm1
22
Thank you. That sorted the problem, After all that, however, it dawned on me that the Project Manager may wish to add a task. As that might be in the middle of the other tasks, my clever (or yours really) solution to automatic numbering ends up causing problems! So actually, manually entering the task order makes more sense after all.

Sorry to waste your time. That said, I just learned a good way of sorting by entry time!!!

Thanks all of you.
Mar 16 '08 #8
NeoPa
32,556 Expert Mod 16PB
I've had that happen to me before.
The question was obviously asked honestly though, so you use whatever is the most appropriate idea available when it comes down to it.
Mar 16 '08 #9
Hulm1
22
Thanks again everyone who helped. How do we close these threads? Is it automatic? or do I do it?

Thanks
Mar 17 '08 #10
NeoPa
32,556 Expert Mod 16PB
They don't get closed unless they are in breach of the rules.

As far as the question goes, they can be considered done with when you post saying you have a solution. That you've done so this one is no longer outstanding.
Mar 17 '08 #11

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

Similar topics

6
by: Jenn L | last post by:
I have a database that is pre-populated with sequential part numbers. As people reserve the parts I update a flag to show the # is no longer available. Now they want the ability to take out a...
5
by: Lapchien | last post by:
I have list of numbers in a table (originally from autonumber in a different database) from 1 to 1,000,000. The list is not in sequential order - there are loads of numbers missing. How can I...
1
by: systems analyst | last post by:
This is my modification on an original solution posted by Trevor Best (trevor@microprism.com) back in 1996. Insert the following code in a Module in your Access data base. Option Compare...
14
by: amywolfie | last post by:
Hi All: I know this is simple, but I just can't seem to get there: I need to sort a table by a text field (txtDescription), then assign sequential numbers to the field SEQUENCE in table. ...
4
by: Bruce | last post by:
Surely someone has done this before, and I am guessing there is a simple solution that is eluding me. I have a simple report based on a recordset. For each record there is a field (RecNum) that...
1
maxamis4
by: maxamis4 | last post by:
Hello folks, I have two forms a parent form and a subform. The parent form is an unbound form while the subform is a form that contains all a list of what I like to call 'in stock ' phone...
6
by: jtidwell | last post by:
I am developing a Work Order Database for my job. I have a combo box with "Contract Numbers" to select from. When you select on any Contract Number I need a new "Work Order Number" to appear. There...
3
by: Finomosec | last post by:
Hi, i have a table of number-objects with beginning and endnr: 10-15 16-20 25-30 32-32 35-35 36-36 37-40
9
by: Axxe | last post by:
I have searched high and low for cogent, well-explained coding to complete a project on which I have spent six months of work. I stumbled across something on this site that is close to what I...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...

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.