next without for error - stumped

  • Thread starter Thread starter Jennifer Robertson
  • Start date Start date
J

Jennifer Robertson

Here is the code

<snip>

'Get the BioAppNo for the current procedure

Set rs1 = db.OpenRecordset(arraySourceTable(9), dbOpenDynaset)
With rs1
currentBioAppNo = rs1.Fields("BioAppNo")
End With

'Loop through all source tables and set null BioAppNo's to the
currentBioAppNo

For z = 0 To 8
Set rs1 = db.OpenRecordset(arraySourceTable(z), dbOpenDynaset)
With rs1
rs1.MoveFirst
Do Until rs1.EOF
If IsNull(rs1.Fields("BioAppNo")) Then
rs1.Edit
rs1.Fields("BioAppNo") = currentBioAppNo
rs1.Update
End If
rs1.MoveNext
Loop
Next z

I know it has something to do with loops or if statements left open, but
they're closed, no?
 
Not sure why you're using the With statement anyway as you aren't then using
it? The purpose of 'With' is to avoid repition, so, if you use it you could
write, e.g.:

With rs1
.MoveFirst
Do Until .EOF
If IsNull(.Fields("BioAppNo")) Then
.Edit
.Fields("BioAppNo") = currentBioAppNo
.Update
End If
.MoveNext
Loop
End With

Hope this helps.

BW
 
Thanks


BeWyched said:
Not sure why you're using the With statement anyway as you aren't then
using
it? The purpose of 'With' is to avoid repition, so, if you use it you
could
write, e.g.:

With rs1
.MoveFirst
Do Until .EOF
If IsNull(.Fields("BioAppNo")) Then
.Edit
.Fields("BioAppNo") = currentBioAppNo
.Update
End If
.MoveNext
Loop
End With

Hope this helps.

BW
 
Back
Top