Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Mike Lewis on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Logic problem... 1

Status
Not open for further replies.

zahara666

Technical User
Nov 1, 2001
78
0
0
CA
You guys have been great with helping me along... I was wondering if someone could take a look at this code and help me with the logic? I can't figure out how to get out of this procedure once it hits the LAST record. Once it gets to the last record, it looks at the next record and because there is no next record it crashes.... I've been working on trying to make this work for a few hours, but my brain is a little muddled now... Here's the code:

If rst.RecordCount = counter Then

rst.MoveFirst
rst.Edit
rst!InvoiceNumber = "E" & start
rst.Update

Else

rst.MoveFirst
rstchk.MoveFirst

Do Until counter = rst.RecordCount

Let cc = rstchk!ClientCode

Do Until (cc <> rstchk!ClientCode)
rst.Edit
rst!InvoiceNumber = &quot;E&quot; & start
rst.Update
Let counter = counter + 1
rst.MoveNext
rstchk.MoveNext
Loop


Let start = start + 1
Loop

End If

as you can see the error is in most inside do loop.

Thanks again for all the help!
Julie
 
Try.
Do Until counter = rst.RecordCount
cc = rstchk!ClientCode
Do Until (cc <> rstchk!ClientCode)
rst.Edit
rst!InvoiceNumber = &quot;E&quot; & start
rst.Update
Let counter = counter + 1
if counter = rst.RecordCount then Exit Do
rst.MoveNext
rstchk.MoveNext
Loop
Loop

Compare Code (Text)
Generate Sort in VB or VBScript
 
Thanks JohnYingling - that worked nicely. I didn't know how to insert an if statement and get out of the do loop.. i.e. didn't know about the Exit Do statement.

Thanks for your help,
Julie
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top