By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,665 Members | 1,912 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,665 IT Pros & Developers. It's quick & easy.

Loop Inside loop for writing text lines

P: n/a
Hi Guys!!!

Thanks in advance for any kind of help about this problem.

The problem:

Acces Database
One Table 'Orders' and second 'OrderItems'

I want to export in txt file using FSO and write all orderitems
ordered by orders.
And i want to write a blankline if the orderitems is more than 5, for
example, in one order.

I try to do using this code:

..........a lot of code here

=================================================
if objrec3("expr1000")<admin("count_lines") Then
objfile.writeline orders_line
objrec1.movenext
else
count = 0

Do While count < admin("count_lines")

objfile.writeline orders_line
count = count+1
if count=admin("count_lines") Then
objfile.writeline
end if
Loop

objrec1.movenext
end if

wend
objrec.movenext
if not objrec.eof AND objrec3("expr1000")<admin("count_lines") Then
objfile.writeline
else
end if
wend
================================================== ===========================
.............. a lot of code here.

"objrec3("expr1000")" is that counts the number of orderitems in one
order.
"admin("count_lines")" is the number of lines that i want to write and
after this number of lines i want to write one blankline if
objrec3("expr1000") is bigger than this.

This code works but it repeats "objrec3("expr1000")", for example 8,
times the "objfile.writeline orders_line", for example 8 times.
How can stop the loop and tell the code to stop repeat it, but
continue with the next "objfile.writeline orders_line"?

Thanks in advance again.
Jul 19 '05 #1
Share this Question
Share on Google+
2 Replies


P: n/a
Why not query the database to have one record per order with the count of
Order Items?
Show me the field names and I'll give you some sample code to do what you
want.

-dlbjr

Discerning resolutions for the alms
Jul 19 '05 #2

P: n/a
"dlbjr" <do******@do.u> wrote in message news:<%qbsb.181$Qy4.14180@typhoon01>...
Why not query the database to have one record per order with the count of
Order Items?
Show me the field names and I'll give you some sample code to do what you
want.

-dlbjr

Discerning resolutions for the alms


Thank you for your reply.

1). The query of orders.
strsql="select OrderID,
CustomerID,OrderDate,TotalSum,OrderItems,OrderStat us from orders WHERE
OrderStatus = 'ok'"

2). The query of orderitems inside while not objrec.eof.. wend.
strsql1="select OrderItemID,OrderID,ProductID,ItemNumber,ItemPrice
from orderitems where orderid = " & orderid
Jul 19 '05 #3

This discussion thread is closed

Replies have been disabled for this discussion.