Loop Inside loop for writing text lines

A

Aggelos

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.
 
D

dlbjr

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
 
A

Aggelos

dlbjr said:
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,OrderStatus 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
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,768
Messages
2,569,574
Members
45,050
Latest member
AngelS122

Latest Threads

Top