C
CraddyP
Guest
Hi,
I am having a problem with a for loop. Heres what im trying to do.
Basically when a new rate set is added for a job in our system the system needs to go back through the timesheet table and update all entries made after the new rate set comes into play.
Each member of staff has a position (eg, Technician, Engineer, Director etc). Rates are stored against position not staff member.
Also instead of dates we are using year periods in the format (000000) Eg. 200401 is the first two weeks of 2004.
Heres the section of code I am having a problem with. The problem is that it only seems to check the first Job number in the timesheet table and then exits. Its probably something really simple I have missed so i'm pretty sure someone will be able to help
---------------------------------------------------------------
-------------------------------------------
Thanks for your time
I am having a problem with a for loop. Heres what im trying to do.
Basically when a new rate set is added for a job in our system the system needs to go back through the timesheet table and update all entries made after the new rate set comes into play.
Each member of staff has a position (eg, Technician, Engineer, Director etc). Rates are stored against position not staff member.
Also instead of dates we are using year periods in the format (000000) Eg. 200401 is the first two weeks of 2004.
Heres the section of code I am having a problem with. The problem is that it only seems to check the first Job number in the timesheet table and then exits. Its probably something really simple I have missed so i'm pretty sure someone will be able to help
---------------------------------------------------------------
Code:
Set rs2 = db.OpenRecordset("TIMESHT")
Set rs3 = db.OpenRecordset("Staff")
rs2.MoveFirst
rs3.MoveFirst
For i = 0 To rs2.RecordCount
If rs2!jobno = Forms![rates]![jobno] Then
If rs2!yr_prd >= Me.DateFinish Then
For k = 0 To rs3.RecordCount
If rs3!stseqno = rs2!stseqno Then
Position = rs3!Position
Select Case Position
Case "Director"
rs2.Edit
rs2!Rate = Me.DirNewRate
rs2.Update
Case "Associate"
rs2.Edit
rs2!Rate = Me.AssocNewRate
rs2.Update
Case "Senior Engineer"
rs2.Edit
rs2!Rate = Me.SenEngNewRate
rs2.Update
Case "Engineer"
rs2.Edit
rs2!Rate = Me.EngNewRate
rs2.Update
Case "Senior Technician"
rs2.Edit
rs2!Rate = Me.SenTechNewRate
rs2.Update
Case "Technician"
rs2.Edit
rs2!Rate = Me.TechNewRate
rs2.Update
Case "Junior Engineer"
rs2.Edit
rs2!Rate = Me.JunEngNewRate
rs2.Update
Case "Graduate Engineer"
rs2.Edit
rs2!Rate = Me.GradEngNewRate
rs2.Update
Case "Trainee"
rs2.Edit
rs2!Rate = Me.TrainNewRate
rs2.Update
Case "Admin Assistant"
rs2.Edit
rs2!Rate = Me.adminNewRate
rs2.Update
Case "Site Monitor"
rs2.Edit
rs2!Rate = Me.SiteMonNewRate
rs2.Update
Case Else
End Select
Else
rs3.MoveNext
If rs3.EOF Then
Exit For
End If
End If
Next k
Else
rs2.MoveNext
If rs2.EOF Then
Exit For
End If
End If
Else
rs2.MoveNext
If rs2.EOF Then
Exit For
End If
End If
Next i
-------------------------------------------
Thanks for your time
Last edited by a moderator: