473,395 Members | 2,437 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,395 software developers and data experts.

Create sequence number using employee ID and start end dates

I am trying to solve a vb sequence number problem which has eluded me for several years now (yes really)

Consider the MS access table below:

Staff Start date End date Sequence
1111 01-Jan-15 04-Jan-15 1
2222 14-Jan-15 16-Jan-15 2
2222 17-Jan-15 22-Jan-15 2
3333 09-Jan-15 13-Jan-15 3
3333 15-Jan-15 23-Jan-15 4
4444 03-Jan-15 03-Jan-15 5
5555 11-Jan-15 11-Jan-15 6
5555 12-Jan-15 24-Jan-15 6
5555 26-Jan-15 28-Jan-15 7
6666 07-Jan-15 22-Jan-15 8

This contains the staff ID numbers and the start and end dates of employees sickness absence. The table is ordered by staff ID and then start date. I need to be able to create a sequence number against each employee based on the start and end dates of their sickness absence. The sequence number only increments under two circumstances firstly, if the employee number changes and secondly (this is the hard bit) if the end date of the previous period of sickness is NOT contiguous with the start date of the next one. Hopefully you should get the idea by looking at the example sequence numbers.

I would really appreciate any help with this as it has me completely stumped. Have I a snippet of code to show you? No I haven't as I have no idea where to start.

Kind regards

Alan
Jan 29 '15 #1
6 1772
twinnyfo
3,653 Expert Mod 2GB
Could you explain the usage of the Sequence number? I understand how you want it to increment, just trying to understand why.

Additionally, when will this sequence number be generated? It could be possible to not have it in the Table at all (as it can become a bit of redundant data. However, I am sure there are ways of doing this. It just depends on how and when the Sequence Number is created.
Jan 29 '15 #2
Hi

Many thanks for the reply the sequence number is used to group absence spells together. If you have a look at my example sequence number 2 starts 14-Jan-15 and ends 22-Jan-15 I am interested in the length [the duration] of the absence (I group on the seq and use a Min Max function to get the total duration) Often the periods of absence go in as two week blocks (for reasons of sick lines etc).

It would be really useful if, say, once the table has been ordered I could then generate and update the table to include the sequence number. I have multiple queries setup to run against the data.

To be honest I can produce the sequence number at the moment however unfortunately I have to do that in Excel before importing the data into access.

Hope this makes sense

Alan
Jan 29 '15 #3
jforbes
1,107 Expert 1GB
Are days off, like weekends, included as records in the Table? Are there voids in dates that need to be tested against another table with valid work days or with a function to determine the difference between a weekday or a weekend?
Jan 29 '15 #4
twinnyfo
3,653 Expert Mod 2GB
If you want to maintain the sequence number in the table, then I would recommend that the sequence number be generated every time you enter a new record (I assume this would/should be on a form).

Once the Staff member, Start and Stop Dates are entered, the code would verify that the data you entered is acceptable (no nulls), then search for the Staff member, evaluating whether the start date is between any of the previously entered absence dates. Do the same for the Just-entered stop date. If there is no match, then increment the max sequence number by one. If there is a match, then find the current sequence number.

I can't provide the code for you, but this should point you in the right direction. I'll be glad to work through any troubleshooting you may come across.
Jan 29 '15 #5
Hi

No weekends etc do not matter simply if by employee number the end date backs on the the start date 15th to 16th, 1st to 2nd etc.

I should have mentioned that essentially I will not be adding in data to the table. The data comes out of our HR system and then is sequenced. When the reports get run next time we again just take the data out of our HR system and sequence it.

Thanks

Alan
Jan 29 '15 #6
twinnyfo
3,653 Expert Mod 2GB
Alan,

So the HR system spits out the data without sequence numbers and then you must update the sequences after the fact?

If that is the case, Then I would create a function that you could call that updates the records (based on the same principles described above).

Could be easily done with a recordset cycling through all records without a sequence number.....
Jan 29 '15 #7

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

Similar topics

2
by: Ken | last post by:
I got an Access database that need to be converted to Oracle 9i. Somehow the Trigger we created to simulate the "AUTO NUMBER" on Access could not create the sequence number as soon as the value has...
4
by: Kamran K | last post by:
Hello I have created a client server application using C#. Existing application is using random number on client side to generate sequence numbers that are then assigned to transactions. This...
1
by: Grant | last post by:
I'm trying to set up the Interchange 5.2 shopping cart (icdevgroup.org) to use the CREATE SEQUENCE functionality of pgsql properly and I'm having some trouble. The table is called order_items and...
12
by: tojigneshshah | last post by:
Hi, I have a situation where i have multiple batch and the each batch are sequence numbers. For each batch, the number should start with 1. For example: Col.no1 Col.no2 ------ ...
1
by: simun.selak | last post by:
On my local installation of DB2 on AS/400 (BTW., how do I find out which version od DB2 I have?) I have created these SQL statements: CREATE SEQUENCE a.seq AS INTEGER START WITH 8955 INCREMENT...
4
by: kudinesh | last post by:
how to create a sequence menttioned below..for number generators. CREATE SEQUENCE sequ START WITH 1 INCREMENT BY 1
21
by: bilgekhan | last post by:
After doing a succcessful insert() or find() on a set<Tcontainer is it possible to get the item number of this item in the set? (ie. its zero-based sequence number (position/location/rank/index)...
2
by: jaka | last post by:
Hi, I'm in need of some expert help in sorting a numerical/alphanumerical employee ID field (5&6 characters in length). Also seperating the alphanumerical IDs and finding the gaps in the...
1
by: kama | last post by:
I want to create sequence number for repeating data values. This sequence number will re-start from 1 for each new value. Example as below:- Amount sequence_number 200 1 200 2...
5
by: chrisbenett | last post by:
Hi all, I want to create an invoice number that looks like "YYMMDD01" which will increment with 1 for each invoice. But the next day, it will need to start at one again. Example: Today:...
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?
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
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
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,...
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...

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.