Can't out of DO...Loop! Help please.

T

TA

Hi ,
I have a piece of code here I don't know where is wrong
but it can not exit Do while loop, please help, Thank you

If Rs_Cum.RecordCount > 0 Then
MsgBox "Do you want to run the Error Checking
Report ?", vbOKCancel
If vbOKCancel = 2 Then
DoCmd.Close
DoCmd.OpenForm "FrmMainMenu"
ElseIf vbOKCancel = 1 Then
Rs_Cum.MoveFirst
Do Until Rs_Cum.EOF
tempID = Trim(Rs_Cum.Fields("ident").Value)
Rs_Cum.MoveNext
If (Rs_Cum.Fields("ident").Value) = tempID Then
Rs3.AddNew
Rs3!Ident = tempID
Rs3!batch = Rs_Cum.Fields("batch").Value
Rs3!seqnum = Rs_Cum.Fields("seqnum").Value
Rs3!Code = "100"
Rs3.Update
Rs_Cum.MovePrevious
Else
Rs_Cum.MovePrevious
End If
Rs_Cum.MoveNext
'MsgBox "end of if and update" OK here
Loop
'MsgBox "Out of loop" NOT OK here
End If ' of vbOKCancel
End If ' of Rs_cum >0
Docmd.close
Docmd.Openform "FrmMainMenu"

It can not close this form and can not open a new form
call FrmMainMenu. Please help Thank you for any suggestion.
TA
 
N

Newbie

If this code is within the form module then you need to open the main form
before you close the form that the code is written

i.e. Docmd.openform "FrmMainMenu"
docmd.close acform, "otherform"

NOT Docmd.close
Docmd.openform "FrmMainMenu"


HTH

Al
 
T

TA

Yeah you right, but the prob. is not here. It ran until
EOF then stop right there and do not thing. I have tried
your ideal but still...?
Thanks for fast reply.
Best Regards,
TA
 
G

Gary Miller

TA,

I think that the following lines are moving you back to the
previous record just before you MoveNext, in effect keeping
you on the same record for the next loop. I am not sure why
they are there, but I don't think they should be.

Rs_Cum.MovePrevious
Else
Rs_Cum.MovePrevious
End If
Rs_Cum.MoveNext
--

Gary Miller
Gary Miller Computer Services
Sisters, OR
________________________
 
T

TA

Thanks Gary.
I intend to remove those lines but program still NOT
working.
Best Regards,
TA
 
G

Gary Miller

Well, it certainly won't until you do, even if you have more
problems than that. Take them out and then see what happens
afterward.

--

Gary Miller
Gary Miller Computer Services
Sisters, OR
________________________
 
T

TA

Hi Gary,
So, I removed these line but ...the problem is still.?
I keep testing now.
Best Regards,
TA
 
G

Gary Miller

TA,

Why don't you post the latest version of what you have so we
can take a fresh look after the changes?

--

Gary Miller
Gary Miller Computer Services
Sisters, OR
________________________
 

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