I have created a recordset based on a table with a WHERE clause. I have four fields in the table:
WellID1
Days1 (rst(2))
MeasDepth1 (rst(3))
Cost1
There are some records in the recordset where the MeasDepth value is null. If it is null for the record corresponding to Days1 = 1, I want to set the MeasDepth =0, else if the value for Days1 > 1, I want to set MeasDepth to the previous record value. I have the first part (where Days1 = 1), but I cannot figure out how to accomplish the second one.
My current code as follows -
Set rst = db.OpenRecordset("Select * from tblTmpDailyCostMP WHERE [WellID1] = '" & strCriteria & "';")
With rst
.MoveFirst
Do While Not .EOF
If rst(2) = 1 And IsNull(rst(3)) Then
.Edit
![MeasDepth1] = "0"
.Update
ElseIf rst(2) > 1 And IsNull(rst(3)) Then
.Edit
![MeasDepth1] = ????
.Update
' .Fields("MeasDepth1") = 2
End If
'Skip past the current record & keep searching
.MoveNext
Loop
'Commit all the changes
'.Update
End With
WellID1
Days1 (rst(2))
MeasDepth1 (rst(3))
Cost1
There are some records in the recordset where the MeasDepth value is null. If it is null for the record corresponding to Days1 = 1, I want to set the MeasDepth =0, else if the value for Days1 > 1, I want to set MeasDepth to the previous record value. I have the first part (where Days1 = 1), but I cannot figure out how to accomplish the second one.
My current code as follows -
Set rst = db.OpenRecordset("Select * from tblTmpDailyCostMP WHERE [WellID1] = '" & strCriteria & "';")
With rst
.MoveFirst
Do While Not .EOF
If rst(2) = 1 And IsNull(rst(3)) Then
.Edit
![MeasDepth1] = "0"
.Update
ElseIf rst(2) > 1 And IsNull(rst(3)) Then
.Edit
![MeasDepth1] = ????
.Update
' .Fields("MeasDepth1") = 2
End If
'Skip past the current record & keep searching
.MoveNext
Loop
'Commit all the changes
'.Update
End With