For...Each statement?

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Krij

    #1

    For...Each statement?

    Hi!

    I've found the problem in my database (ms access 2000). The ting is
    that returning two or more orderlines requieres that both item has the
    same ItemID. When returning two different itemID, the first one only
    will be returned. I can see the logic, I believe.

    Her is the code:

    A button on frmOrders will let user return an order.

    strPutBack = "INSERT INTO tblAmountItems( Amount,MyDate,R eturned) " _
    & "SELECT Amount,MyDate,R eturned " _
    & "FROM tblOrderdetails " _
    & "WHERE tblOrderdetails .Returned = True
    AND tblOrderdetails .ItemID = " &
    Forms!frmOrders !frmOrderdetail s!ItemID
    AND tblOrderdetails .OrderID = " & Forms!frmOrders !OrderID;"

    CurrentDb.Execu te strPutBack, dbFailOnError

    Now my question is:

    Could I use a For ... Each here in order to have the code insert each
    ItemID to the tblAmountItems? Or is there any other way to make the
    code repeat itself and not stop before
    all ItemID are returned?

    Should I use a recordset object here?

    Questions....qu estion....AAAaa aaaaaaaaaaaa... ............... ..

    Thank you :-)

    Me.Name

  • Krij

    #2
    Re: For...Each statement?

    Krij skrev:
    Hi!
    >
    I've found the problem in my database (ms access 2000). The ting is
    that returning two or more orderlines requieres that both item has the
    same ItemID. When returning two different itemID, the first one only
    will be returned. I can see the logic, I believe.
    >
    Her is the code:
    >
    A button on frmOrders will let user return an order.
    >
    strPutBack = "INSERT INTO tblAmountItems( Amount,MyDate,R eturned) " _
    & "SELECT Amount,MyDate,R eturned " _
    & "FROM tblOrderdetails " _
    & "WHERE tblOrderdetails .Returned = True
    AND tblOrderdetails .ItemID = " &
    Forms!frmOrders !frmOrderdetail s!ItemID
    AND tblOrderdetails .OrderID = " & Forms!frmOrders !OrderID;"
    >
    CurrentDb.Execu te strPutBack, dbFailOnError
    >
    Now my question is:
    >
    Could I use a For ... Each here in order to have the code insert each
    ItemID to the tblAmountItems? Or is there any other way to make the
    code repeat itself and not stop before
    all ItemID are returned?
    >
    Should I use a recordset object here?
    >
    Questions....qu estion....AAAaa aaaaaaaaaaaa... ............... ..
    >
    Thank you :-)
    >
    Me.Name

    I solved the problem with help on the web. I just had yo remove the
    ItemID like:

    strPutBack = "INSERT INTO tblAmountItems( ItemID,Amount,M yDate,Returned)
    " _
    & "SELECT ItemID,Amount,N ow(),Returned " _
    & "FROM tblOrderdetails " _
    & "WHERE tblOrderdetails .OrderID = " &
    Forms!frmOrders !frmOrderdetail s!OrderID " _
    & "AND tblOrderdetails .Returned = True;"

    :-)

    Comment

    Working...