Hello,
I am attempting to create a nested loop (in Access 2003/VB) that will print a report for a set of user defined months inputed on a form and that will print out for every Client. So the first loop would increment the Client by 1, then the second loop would increment the Month by 1. So the first time around Client A for Month 1, then Client A for month 2 then Client B for Month 1 and so on. Below is what I have already, I can get the nested loop to work and increment the months, but am having a heck of a time incrementing the outer loop (Client). Below is my code so far. Thanks in advance for your help. -
Private Sub Print_All_SB165_Click()
-
-
Dim stDocName As String
-
stDocName = "CFDMonthlyReportALLMONTH"
-
-
Dim i As Integer
-
i = 1
-
Dim x As Integer
-
x = 0
-
-
Do
-
-
Do While Forms!ReportChooser!AllMonth.ItemData(x) <> ""
-
Forms!ReportChooser!Month = Forms!ReportChooser!AllMonth.ItemData(x)
-
Forms!ReportChooser!Client_Box = Forms!ReportChooser!Client_All.ItemData(i)
-
-
DoCmd.RunMacro "OpenQNOTE"
-
-
DoCmd.OpenReport stDocName, acNormal
-
-
DoCmd.RunMacro "CloseQNOTE"
-
-
x = x + 1
-
Loop
-
i = i + 1
-
Loop Until Forms!ReportChooser!Client_Box.ItemData(i) = ""
-
-
End Sub
-
12 3542
I wasn't going to reply since this isn't really my area. But since nobody else has put their oar in yet...
One thing which jumped out at me is that this line... - Forms!ReportChooser!Client_Box = Forms!ReportChooser!Client_All.ItemData(i)
appears to be moving a single element (i) to Client_Box, then this line... - Loop Until Forms!ReportChooser!Client_Box.ItemData(i) = ""
is testing element (i) from Client_Box. Something just doesn't seem to add up here.
I'll take this pure guess-work one step further - perhaps at the end of the outer loop, you should be testing Client_All.Item Data(i) instead of Client_Box.Item Data(i) ?
Thank you for your response. I completely understand what you are saying...the reason I set it up that way was because I could not figure out how to initialize the increment...I had to assign (i) to Client somehow to increment the data...I'm assuming there has to be a better way but I don't know what that is.
I wasn't going to reply since this isn't really my area. But since nobody else has put their oar in yet...
One thing which jumped out at me is that this line... - Forms!ReportChooser!Client_Box = Forms!ReportChooser!Client_All.ItemData(i)
appears to be moving a single element (i) to Client_Box, then this line... - Loop Until Forms!ReportChooser!Client_Box.ItemData(i) = ""
is testing element (i) from Client_Box. Something just doesn't seem to add up here.
I'll take this pure guess-work one step further - perhaps at the end of the outer loop, you should be testing Client_All.Item Data(i) instead of Client_Box.Item Data(i) ?
Thank you for your response. I completely understand what you are saying...the reason I set it up that way was because I could not figure out how to initialize the increment...I had to assign (i) to Client somehow to increment the data...I'm assuming there has to be a better way but I don't know what that is.
Sorry I can't be of more help, but did you try the suggestion of testing Client_All.Item Data(i) instead of Client_Box.Item Data(i) in the Loop Until? In other words... - Loop Until Forms!ReportChooser!Client_All.ItemData(i) = ""
Thank you for trying...I appreciate it...I did try your suggestion but still could not get it to work...I think I'm going to take a day or two without looking at it and then go back to it to get some new perspective. Thanks again for your help.
Sorry I can't be of more help, but did you try the suggestion of testing Client_All.Item Data(i) instead of Client_Box.Item Data(i) in the Loop Until? In other words... - Loop Until Forms!ReportChooser!Client_All.ItemData(i) = ""
Thank you for trying...I appreciate it...I did try your suggestion but still could not get it to work...I think I'm going to take a day or two without looking at it and then go back to it to get some new perspective. Thanks again for your help.
Let us know how it turns out.
Let us know how it turns out.
hi
'do while' is no proper statement
better take 2nd loop as while...wend
hi
'do while' is no proper statement
better take 2nd loop as while...wend
When you say it's "no proper statement" is this a style thing, or what? It is certainly a valid statement, at least in VB6. Dunno about Access.
When you say it's "no proper statement" is this a style thing, or what? It is certainly a valid statement, at least in VB6. Dunno about Access.
hi
do while ... wants to have a value before calculation
in this case the value from the previous loop is used.
if you use 'while' or 'do' only, the new value is taken.
do while ... wants to have a value before calculation
in this case the value from the previous loop is used. if you use 'while' or 'do' only, the new value is taken.
Interesting. I wasn't aware of the difference.
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Martin Schou |
last post by:
Please ignore the extreme simplicity of the task :-) I'm new to C,
which explains why I'm doing an exercise like this.
In the following tripple nested loop:
int digit1 = 1;
int digit2 = 0;
int digit3 = 0;
for( ; digit1 < 5 ; digit1++ )
{
|
by: Neptune |
last post by:
Hello.
I am working my way through Zhang's "Teach yourself C in 24 hrs (2e)"
(Sam's series), and for nested loops, he writes (p116) "It's often
necessary to create a loop even when you are already in a loop." Then he
goes on to portray a contrived example that doesn't tell me under what
conditions a nested loop might be favoured as a solution? i.e. what are
nested loops useful for? What kinds of algorithms are served by nested
loops?...
|
by: Peter Olcott |
last post by:
http://www.tommti-systems.de/go.html?http://www.tommti-systems.de/main-Dateien/reviews/languages/benchmarks.html
Why is C# 500% slower than C++ on Nested Loops ???
Will this problem be solved in the future???
|
by: Peter Olcott |
last post by:
http://www.tommti-systems.de/go.html?http://www.tommti-systems.de/main-Dateien/reviews/languages/benchmarks.html
The above link shows that C# is 450% slower on something as simple as a nested
loop. Is this because .NET is inherently slower or does the C# compiler merely
produce code that is not as well optimized as the C++ compiler?
|
by: th3dude |
last post by:
I am trying to pull out some nested XML using C# and XMLReader.
Can't seem to extract the "Items" for each "Product" when i loop
through file, i can loop over the "Product" notes just fine but
everytime i perform a nested loop over the "Items" list i keep every
item on the file listed for each "Product".
Is there an easy approach to get the related Items for each Product ID
instead of all the Items everytime?
| |
by: MDR |
last post by:
Hello
I have three "for" loops, two nested into the outer one and they depend on each other, like this:
for (x=1; x<100; x++)
{
....
for (i=1; i<10; i++)
{....}
for (j=1; j<10; j++)
|
by: notahipee |
last post by:
Would someone be able to tell me why this isn't working. The nested
for loops seem correctly coded to me. I would appreciate any input.
#include <iostream.h>
#include <math.h>
int main ()
{
int a, b, c, d;
|
by: numlock00 |
last post by:
I have a nested 'while' loop that won't repeat, no matter how many times the outer loop repeats. The outer loop reads through an array of elements; the inner loop Ithe 'while' loop) is supposed to apply each of these elements while reading an input file.
The outer loop is working fine. It will run through every element of the array. The inner loop, however, only runs once. Even though the outer loop finishes inormally, the inner loop does not...
|
by: Nathan Sokalski |
last post by:
I have several nested For loops, as follows:
For a As Integer = 0 To 255
For b As Integer = 0 To 255
For c As Integer = 0 To 255
If <Boolean ExpressionThen <My CodeElse Exit For
Next
If Not <Boolean ExpressionThen Exit For
Next
If Not <Boolean ExpressionThen Exit For
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look !
Part I. Meaning of...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
| |
by: jinu1996 |
last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert into image.
Globals.ThisAddIn.Application.ActiveDocument.Select();...
|
by: TSSRALBI |
last post by:
Hello
I'm a network technician in training and I need your help.
I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs.
The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols.
I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
|
by: adsilva |
last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
|
by: 6302768590 |
last post by:
Hai team
i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...
| |