Hi,
Can anybody help me, I'm getting a error message with the following code. The error message is RUN-TIME ERROR '3021' NO CURRENT RECORD.
What I'm trying to do is to update a value in one table from another table. The table I'm updating has a one-to-many relationship with the table which I'm updating from, and the error message occures at the very end after it has updated the records.
Regards
Paul L
Public Function Update_Lvl3()
Dim db As Database, level3 As Recordset, Activ As Recordset, ReturnValue As Variant
Set db = CurrentDb()
Set level3 = db.OpenRecordset("SELECT DISTINCTROW LEVEL_3_DETAILS.* FROM LEVEL_3_DETAILS ORDER BY ACP_NO;")
Set Activ = db.OpenRecordset("SELECT DISTINCTROW RESOURCES.* FROM RESOURCES ORDER BY ACP_NO;")
DoCmd.Hourglass True
Do While Not level3.NoMatch
CURRENT_ESTIMATE = 0#
EARNED_HOURS = 0#
Do While level3!ACP_NO = Activ!ACP_NO
CURRENT_ESTIMATE = CURRENT_ESTIMATE + (Activ![WEIGHTING])
EARNED_HOURS = EARNED_HOURS + (Activ![PROGRESS_WEIGHT])
Activ.MoveNext
Loop
level3.LockEdits = False
level3.Edit
level3!CURRENT_ESTIMATE = CURRENT_ESTIMATE
level3!EARNED_HOURS = EARNED_HOURS
If level3!CURRENT_ESTIMATE = 0 Or level3!EARNED_HOURS = 0 Then
level3!Percent_Complete = 0
Else
level3!Percent_Complete = (level3!EARNED_HOURS / level3!CURRENT_ESTIMATE) * 100
End If
If level3!CURRENT_ESTIMATE <> 0 Then
If level3!PRODUCTIVITY = 0 Then
level3!FORECAST_REMAINING = level3!CURRENT_ESTIMATE - level3!EARNED_HOURS
Else
level3!FORECAST_REMAINING = (level3!CURRENT_ESTIMATE - level3!EARNED_HOURS) / level3!PRODUCTIVITY
End If
Else
level3!FORECAST_REMAINING = level3!CURRENT_ESTIMATE
End If
level3.Update
level3.MoveNext
Loop
level3.LockEdits = True
DoCmd.Hourglass False
End Function
Can anybody help me, I'm getting a error message with the following code. The error message is RUN-TIME ERROR '3021' NO CURRENT RECORD.
What I'm trying to do is to update a value in one table from another table. The table I'm updating has a one-to-many relationship with the table which I'm updating from, and the error message occures at the very end after it has updated the records.
Regards
Paul L
Public Function Update_Lvl3()
Dim db As Database, level3 As Recordset, Activ As Recordset, ReturnValue As Variant
Set db = CurrentDb()
Set level3 = db.OpenRecordset("SELECT DISTINCTROW LEVEL_3_DETAILS.* FROM LEVEL_3_DETAILS ORDER BY ACP_NO;")
Set Activ = db.OpenRecordset("SELECT DISTINCTROW RESOURCES.* FROM RESOURCES ORDER BY ACP_NO;")
DoCmd.Hourglass True
Do While Not level3.NoMatch
CURRENT_ESTIMATE = 0#
EARNED_HOURS = 0#
Do While level3!ACP_NO = Activ!ACP_NO
CURRENT_ESTIMATE = CURRENT_ESTIMATE + (Activ![WEIGHTING])
EARNED_HOURS = EARNED_HOURS + (Activ![PROGRESS_WEIGHT])
Activ.MoveNext
Loop
level3.LockEdits = False
level3.Edit
level3!CURRENT_ESTIMATE = CURRENT_ESTIMATE
level3!EARNED_HOURS = EARNED_HOURS
If level3!CURRENT_ESTIMATE = 0 Or level3!EARNED_HOURS = 0 Then
level3!Percent_Complete = 0
Else
level3!Percent_Complete = (level3!EARNED_HOURS / level3!CURRENT_ESTIMATE) * 100
End If
If level3!CURRENT_ESTIMATE <> 0 Then
If level3!PRODUCTIVITY = 0 Then
level3!FORECAST_REMAINING = level3!CURRENT_ESTIMATE - level3!EARNED_HOURS
Else
level3!FORECAST_REMAINING = (level3!CURRENT_ESTIMATE - level3!EARNED_HOURS) / level3!PRODUCTIVITY
End If
Else
level3!FORECAST_REMAINING = level3!CURRENT_ESTIMATE
End If
level3.Update
level3.MoveNext
Loop
level3.LockEdits = True
DoCmd.Hourglass False
End Function