Loop Inside loop for writing text lines

Discussion in 'ASP General' started by Aggelos, Nov 11, 2003.

  1. Aggelos

    Aggelos Guest

    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.
     
    Aggelos, Nov 11, 2003
    #1
    1. Advertising

  2. Aggelos

    dlbjr Guest

    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
     
    dlbjr, Nov 11, 2003
    #2
    1. Advertising

  3. Aggelos

    Aggelos Guest

    "dlbjr" <> 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,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
     
    Aggelos, Nov 12, 2003
    #3
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Alexander Korsunsky

    break inside of case- statement inside of loop

    Alexander Korsunsky, Feb 25, 2007, in forum: C Programming
    Replies:
    25
    Views:
    1,088
    Richard Heathfield
    Feb 27, 2007
  2. Murali
    Replies:
    2
    Views:
    595
    Jerry Coffin
    Mar 9, 2006
  3. Matthew Huggett
    Replies:
    2
    Views:
    212
    Hidetoshi NAGAI
    Feb 15, 2004
  4. Cah Sableng
    Replies:
    0
    Views:
    247
    Cah Sableng
    Apr 23, 2007
  5. Isaac Won
    Replies:
    9
    Views:
    407
    Ulrich Eckhardt
    Mar 4, 2013
Loading...

Share This Page