next without for error - stumped

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?
 
B

BeWyched

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
 
J

Jennifer Robertson

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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top