loops and operators
The UK's Number 1 for Microsoft Office Training Add this page to your favourites/bookmarksBookmark page
 
View printable version of pagePrintable version
Plus One Google
Customer: Sign in
Delegate: Sign in
Trainer: Log in

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

Loops and operators

resolvedResolved · Urgent Priority · Version 2003

replyReply Mon 20 Oct 2008, 11:37Delegate Gillian said...

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

For upcoming training course dates see: Pricing & availability

replyReply Mon 20 Oct 2008, 16:02Trainer Stephen said...

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

replyReply Mon 20 Oct 2008, 16:08Delegate Gillian said...

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

replyReply Tue 21 Oct 2008, 16:12Trainer Stephen said...

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 stephenATmicrosofttraining.net

Regards

Stephen

replyReply Tue 21 Oct 2008, 16:44Delegate Gillian said...

RE: Loops and operators

Thanks Stephen, I am emailing it to you now.

Gillian

 

Please browse our web site to find out more about
microsoft.access.courses and other Microsoft training courses.

Access tip:

Space marks

It is good practice not i to have space marks for field names as this can lead to problems when using queries or VBA code. It is much better to use an underscore charcter to represent spaces in field names

View all Access hints and tips


Microsoft Certified Partner Accredited Training Provider: Institute of IT Training Institute of Leadership and Management - Certified Courses Security Seal verified by visa, mastercard securecard