I'm sure this has been posted many times, but I never had a need until now.
- I have a DB that tracks engineering jobs.
- Each JOB can have many TASKS.
- I need to track each TASK by a unique ID number in this format:
YYYY - JOB# - TASK#
Each Job number is sequential starting at 1 on January 1st.
Each Task number is sequential starting at 1 with each new JOB.
For example:
2008-37-02 is the 2nd task of the 37th job in the year 2008.
Every new JOB moves starts the task counter back to 1.
Every new YEAR starts the JOB numbers back to 1.
What is the best way to do this?
Thanks!
Peter
3 1260
I think the best way is to have two tables, a job table and a task table, the job number would be the primary key of the job table and the task number would be the primary key of the task table, the task table should contain a foreign key of the job table ID. You can then add as many related tasks as you need for the associated job table.
I'm sure this has been posted many times, but I never had a need until now.
- I have a DB that tracks engineering jobs.
- Each JOB can have many TASKS.
- I need to track each TASK by a unique ID number in this format:
YYYY - JOB# - TASK#
Each Job number is sequential starting at 1 on January 1st.
Each Task number is sequential starting at 1 with each new JOB.
For example:
2008-37-02 is the 2nd task of the 37th job in the year 2008.
Every new JOB moves starts the task counter back to 1.
Every new YEAR starts the JOB numbers back to 1.
What is the best way to do this?
Thanks!
Peter
How do you know when an old job has finished and a new one begun, this is the critical question.
I'm sure this has been posted many times, but I never had a need until now.
- I have a DB that tracks engineering jobs.
- Each JOB can have many TASKS.
- I need to track each TASK by a unique ID number in this format:
YYYY - JOB# - TASK#
Each Job number is sequential starting at 1 on January 1st.
Each Task number is sequential starting at 1 with each new JOB.
For example:
2008-37-02 is the 2nd task of the 37th job in the year 2008.
Every new JOB moves starts the task counter back to 1.
Every new YEAR starts the JOB numbers back to 1.
What is the best way to do this?
Thanks!
Peter
The basic logic to generate the next, sequential, TaskID Number, minus the missing critical piece of information listed previously in Post #3 would be something similar to: -
Public Function fGenerateNextTaskID() As String
-
'Task ID Format: YYYY-JJ-TT (Year - Job# - Task#)
-
Dim strLastTaskID As String
-
Dim intLastTaskIDYear As Integer
-
Dim intLastTaskIDJobNum As Integer
-
Dim intLastTaskIDTaskNum As Integer
-
-
Dim intNextTaskIDYear As Integer
-
Dim intNextTaskIDJobNum As Integer
-
Dim intNextTaskIDTaskNum As Integer
-
-
strLastTaskID = DLast("[TaskID]", "tblTasks")
-
-
intLastTaskIDYear = Val(Left$(strLastTaskID, 4))
-
intLastTaskIDJobNum = Val(Mid$(strLastTaskID, 6, 2))
-
intLastTaskIDTaskNum = Val(Right$(strLastTaskID, 2))
-
-
If Val(intLastTaskIDYear) = Year(Date) Then 'Not a New Year
-
intNextTaskIDYear = intLastTaskIDYear
-
Else
-
intNextTaskIDYear = intLastTaskIDYear + 1 'New Year, increment by 1
-
End If
-
-
'Missing information concerning Job Number
-
'If Job Number is the same
-
intNextTaskIDJobNum = intLastTaskIDJobNum 'maintain Current Job#
-
intNextTaskIDTaskNum = intLastTaskIDTaskNum + 1 'increment Task#
-
'Else
-
intNextTaskIDJobNum = intLastTaskIDJobNum + 1 'increment Current Job#
-
intNextTaskIDTaskNum = 1 'Reset Task# to 1
-
'End If
-
-
fGenerateNextTaskID = CStr(intNextTaskIDYear) + "-" & Format$(intNextTaskIDJobNum, "00") & _
-
"-" & Format$(intNextTaskIDTaskNum, "00")
-
End Function
NOTE: This code requires a strick adherence to the TaskID Format of: YYYY-JJ-TT and a seeding of the 1st ID, meaning that you need only a single, manually entered ID, for the code to work.
Sign in to post your reply or Sign up for a free account.
Similar topics
by: Brandon J. Van Every |
last post by:
What's better about Ruby than Python? I'm sure there's something. What is
it?
This is not a troll. I'm language shopping and I want people's answers. I
don't know beans about Ruby or have...
|
by: david |
last post by:
I write a program which returns the maximum of three input integers.
both can run weil in the DEV-C++ , but I just wonder which one is
better,
and I also want to make it clear that if I use the...
|
by: brian.digipimp |
last post by:
I turned this in for my programming fundamentals class for our second
exam. I am a c++ newb, this is my first class I've taken. I got a good
grade on this project I'm just wondering if there is a...
|
by: jquest |
last post by:
Hi Again;
I have had help from this group before and want to thank everyone,
especially PCDatasheet.
My database includes a field called HomePhone, it uses the (xxx)xxx-xxx
format to include...
|
by: Ben Justice |
last post by:
For a program in c, I need some random numbers for a system were people are
placing bets. This is not a commerical project btw. Generally, I tend to
rely on things from the standard library,...
|
by: darklight |
last post by:
Q: write a program so that it excepts six even numbers
or until the number 99 is entered
please explain why one is better than the other,
if that is the case.
A1:
/*EX6-1.C TO COUNT AND...
|
by: Vidéotron |
last post by:
Hi,
A bit new to "more complex" expression... So here the case I have:
bla bla bla{TPL,some texte or numbers}bla bla bla.
I figured out how to write the expression to extract the "{TPL,some...
|
by: weidongtom |
last post by:
Hi,
I was working on the following problem and I managed to get a
solution, but it's too slow. And I am still in search for a better
algorithm. Please enlighten me.
...
|
by: Masood |
last post by:
I know that this topic may inflame the "C language Taleban", but is
there any prospect of some of the neat features of C++ getting
incorporated in C? No I am not talking out the OO stuff. I am...
|
by: mike3 |
last post by:
Hi.
(Xposted to both comp.lang.c++ and comp.programming since I've got
questions related to both C++ language and general programming)
I've got the following C++ code. The first routine runs in...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
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...
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
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...
|
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...
|
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,...
|
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: 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...
|
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,...
| |