Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
Home
Discussion GroupsFormsForms ProgrammingQueriesModules / DAO / VBAReports / PrintingMacrosDatabase DesignSecurityConversionImporting / LinkingSQL Server / ADPMultiuser / NetworkingReplicationSetup / ConfigurationDeveloper ToolkitsActiveX ControlsNew UsersGeneral 1General 2
Access DirectoryToolsTutorialsUser Groups
Related Topics
SQL ServerOther DB ProductsMS OfficeMore Topics ...

MS Access Forum / Modules / DAO / VBA / November 2006

Tip: Looking for answers? Try searching our database.

For x = 1 to Variable

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Lythandra - 08 Nov 2006 19:46 GMT
Hi there,

I'm using the line: For x = 1 to Variable, where Variable is a integer.

Now it all works well but if a certain condition happens, then Variable can
go up by 1.

Now Variable will show that it has indeed gone up by one BUT the: For x = 1
to Variable, will still go by the orginal number not the amended number.

Has anyone run into this before and know a way to get it to work the way
that I would like it to?

Thanks
Lythandra - 08 Nov 2006 19:58 GMT
Nevermind,

I just called the sub again then put an "Exit Sub" right behind it.

It may not be exacly the way I want it to work but as long as it works.  :-)

> Hi there,
>
[quoted text clipped - 10 lines]
>
> Thanks
Roger Carlson - 08 Nov 2006 20:01 GMT
Instead of a For...Next loop, use a Do While...Loop

x=1
Do While x < Variable
'body of the loop
x=x+1
Loop

Signature

--Roger Carlson
 MS Access MVP
 Access Database Samples: www.rogersaccesslibrary.com
 Want answers to your Access questions in your Email?
 Free subscription:
 http://peach.ease.lsoft.com/scripts/wa.exe?SUBED1=ACCESS-L

> Hi there,
>
[quoted text clipped - 10 lines]
>
> Thanks
Stefan Hoffmann - 09 Nov 2006 09:33 GMT
hi,

> I'm using the line: For x = 1 to Variable, where Variable is a integer.
This line is evaluated once.

> Now it all works well but if a certain condition happens, then Variable can
> go up by 1.
This change can't be reflected for the loop, because it will not
reevaluate the loop header.

> Has anyone run into this before and know a way to get it to work the way
> that I would like it to?
Use Roger's solution.

mfG
--> stefan <--
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.