Cosmos75
Registered User.
- Local time
- Yesterday, 20:09
- Joined
- Apr 22, 2002
- Messages
- 1,281
More problems..
Travis,
Thank you for your code, finally found the time to try it out and look at it closely.
Would it be too much to ask what your code is doing?
I think understand the flow..
What is this?
Dim rst As ADODB.Recordset
Set rst = New ADODB.Recordset
rst.Open "Select Top 1 SubTaskID From tblSubTask Where [TaskID]=" & TaskID & " Order by [SubTaskID] Desc", Application.CurrentProject.Connection, adOpenStatic, adLockReadOnly
Are you creating a query that selects the Highest SubTaskID for the current TaskID, what is the rest of it??
If rst.RecordCount = 0 Then
GetLastSubTaskID = 1
Else
GetLastSubTaskID = rst!SubTaskID + 1
End If
End Function
Here is's IF no SubTaskID for this TaskID, then SubTaskID is 1, ELSE add 1 to the Highest SubTaskID.
I assume if the SubTaskID were to be renamed, I could still use GetLastSubTaskID in the code as the function name but would have to replace rst!SubTaskID and the OrderBy..
I'll have to change this code since my tables are split up. Not familiar with Access VBA but am willing to try and modify the code if you can tell me what the statements do. Probably use a Make-table query to put the exisiting TaskID and SubTaskIDs in a table that the code can refer to.
Another problem that has popped up, is that now, there are two project numbers. I've just put the two projecy numbers in a table, and put a lookup field to tblSubTask (i.e. Project number that the SubTask is charging to.
SO, now each ProjectNumber/TaskID/SubTaskID needs to be unique
Now, I have
Project1, Task1,SubTask1
Project1, Task1,SubTask2
Project1, Task1,SubTask3
Project2, Task1,SubTask1
Project2, Task1,SubTask2
Project2, Task1,SubTask3
and need to increment SubTaskID, not only by TaskID but also but ProjectNumber abd TaskID!!
Sigh...
Any help you can offer me will be greatly appreciated!
Travis,
Thank you for your code, finally found the time to try it out and look at it closely.
Would it be too much to ask what your code is doing?
I think understand the flow..
What is this?
Dim rst As ADODB.Recordset
Set rst = New ADODB.Recordset
rst.Open "Select Top 1 SubTaskID From tblSubTask Where [TaskID]=" & TaskID & " Order by [SubTaskID] Desc", Application.CurrentProject.Connection, adOpenStatic, adLockReadOnly
Are you creating a query that selects the Highest SubTaskID for the current TaskID, what is the rest of it??
If rst.RecordCount = 0 Then
GetLastSubTaskID = 1
Else
GetLastSubTaskID = rst!SubTaskID + 1
End If
End Function
Here is's IF no SubTaskID for this TaskID, then SubTaskID is 1, ELSE add 1 to the Highest SubTaskID.
I assume if the SubTaskID were to be renamed, I could still use GetLastSubTaskID in the code as the function name but would have to replace rst!SubTaskID and the OrderBy..
I'll have to change this code since my tables are split up. Not familiar with Access VBA but am willing to try and modify the code if you can tell me what the statements do. Probably use a Make-table query to put the exisiting TaskID and SubTaskIDs in a table that the code can refer to.
Another problem that has popped up, is that now, there are two project numbers. I've just put the two projecy numbers in a table, and put a lookup field to tblSubTask (i.e. Project number that the SubTask is charging to.
SO, now each ProjectNumber/TaskID/SubTaskID needs to be unique

Now, I have
Project1, Task1,SubTask1
Project1, Task1,SubTask2
Project1, Task1,SubTask3
Project2, Task1,SubTask1
Project2, Task1,SubTask2
Project2, Task1,SubTask3
and need to increment SubTaskID, not only by TaskID but also but ProjectNumber abd TaskID!!

Sigh...

Any help you can offer me will be greatly appreciated!