loops and operators

Public Schedule Face-to-Face & Online Instructor-Led Training - View dates & book

Forum home » Delegate support and help forum » Microsoft Access VBA Training and help » Loops and operators

Loops and operators

resolvedResolved · Urgent Priority · Version 2003

Gillian has attended:
Access VBA course
Excel Advanced course

Loops and operators

Hi,
I have a Do-While loop that works OK, until I change some of the If conditions from a field value = 1 to the same field value >=1.
Here is the code:
With rstNames
.MoveFirst
For intCount = 1 To .RecordCount
If .Fields("GPFnWords").Value = 1 And .Fields("PFnWords") = 1 And .Fields("FnTotalMatch") = "N" Then
i = 0
Do
.Edit
.Fields("FnLeftRight1_1") = i
.Update
i = i + 1
Loop While Left(.Fields("GPFn1"), i) = Left(.Fields("PFn1"), i)
End If

Why if I change .Fields("GPFnWords").Value >= 1, does the loop no longer work at i = i+1?

Thankyou

RE: Loops and operators

Hi Gillian

Thank you for your question

Can you clarify for me whether your code causes a run time error. If so then could you tell me the number and description.

If not, then what does it do that is incorrect

Regards

Stephen

RE: Loops and operators

Hi Stephen, it says 'run-time error 6: over-flow' and highlights the code i=i+1.
This only happens when I change the field value to >=1 rather than =1.

Thanks,
Gill

RE: Loops and operators

Hi Gillian

Thanks for that

It is very hard to figure out the problem without seeing the recordsets that the code refers to. Could you email me the database, and I will have a look and see if I can resolve the issue.

My email is stephenATstl-training.co.uk

Regards

Stephen

RE: Loops and operators

Thanks Stephen, I am emailing it to you now.

Gillian

 

Training courses

 

Training information:

Welcome. Please choose your application (eg. Excel) and then post your question.

Our Microsoft Qualified trainers will then respond within 24 hours (working days).

Frequently Asked Questions
What does 'Resolved' mean?

Any suggestions, questions or comments? Please post in the Improve the forum thread.


 

Access tip:

Modal forms

If you have created a form / switchboard and dont want people to get away from using the switchboard, you can change the form properites for Modal to On.

View all Access hints and tips


Server loaded in 0.08 secs.