Advertisement
If you have a new account but are having problems posting or verifying your account, please email us on hello@boards.ie for help. Thanks :)
Hello all! Please ensure that you are posting a new thread or question in the appropriate forum. The Feedback forum is overwhelmed with questions that are having to be moved elsewhere. If you need help to verify your account contact hello@boards.ie

Insert Form loop question

Options
  • 01-10-2008 3:59pm
    #1
    Registered Users Posts: 224 ✭✭


    Hi All,

    Trying to get this loop working. basically I have a form which contains 2 types of info...item descriptives and item prices.

    I need the form to do the following;

    for every qty thats submitted, it'll be posted to a line in a tbl along with the item descriptives. So if you submit 3 prices, 3 rows will be inserted into the tbl with the item descriptives repeated in each row.

    Here is my insert statement which "allows" for 5 price breaks. The only problem is that when i submit the form its taking the first line in the table and repeating it 5 times in the table.

    Any ideas?

    ******************
    <%
    Do Until iCnt = 5
    iSupplierID = rsInsertRQ.fields.item("SupplierID").value
    sdescription = rsInsertRQ.fields.item("Description").value
    sGroupcode = rsInsertRQ.fields.item("GroupCode").value
    sCollectLocation = rsInsertRQ.fields.item("CollectLocation").value
    sPackSpecs = rsInsertRQ.fields.item("PackingSpecs").value
    sSalesMail = rsInsertRQ.fields.item("SaleseMail").value
    sDesc1 = rsInsertRQ.fields.item("Desc1").value
    sImageling = rsInsertRQ.fields.item("Imagelink").value
    sValidTill = rsInsertRQ.fields.item("ValidTill").value
    dCurrency = rsInsertRQ.fields.item("Currency").value


    iQty = rsInsertRQ.fields.item("Qty").value
    iRangeA = rsInsertRQ.fields.item("RangeA").value
    iRangeB = rsInsertRQ.fields.item("RangeB").value
    iCost = rsInsertRQ.fields.item("Cost").value
    iMargin = rsInsertRQ.fields.item("Margin").value

    sSQL = "INSERT INTO TblQuote(Supplierid,Description,Groupcode,COLLECTLOCATION,PackingSpecs,salesemail,Desc1,imagelink,validtill,Currency,Qty,RangeA,RangeB,Cost,margin)" & _
    " Values ('" & _
    iSupplierID & "','" & sdescription & "','" & sGroupcode & "','" & sCollectLocation & "','" & sPackingSpecs & "','" & sSaleseMail & "','" & sDesc1 & "','" & sImagelink & "','" & sValidTill & "','" & dCurrency & "'," & iQty & "," & iRangeA & "," & iRangeB & "," & iCost & "," & iMargin & ")"
    ExecuteCommand sSQL
    iCnt = iCnt + 1
    Loop
    %>


Comments

  • Closed Accounts Posts: 17,208 ✭✭✭✭aidan_walsh


    Doesn't look like you're incrementing to the next line to me.


  • Registered Users Posts: 224 ✭✭The Mighty Dubs


    Doesn't look like you're incrementing to the next line to me.

    Hi Aidan,

    You'll have to excuse my ignorance here, but how would i increment it.


  • Closed Accounts Posts: 17,208 ✭✭✭✭aidan_walsh


    I'm not really an ASP head so I could be completely wrong here, but if you do rsInsertRQ.MoveNext after processing the SQL record it should jump to the next input value.


  • Registered Users Posts: 224 ✭✭The Mighty Dubs


    I'm not really an ASP head so I could be completely wrong here, but if you do rsInsertRQ.MoveNext after processing the SQL record it should jump to the next input value.

    Will give that a lash and hopefully will do the trick...cheers


  • Registered Users Posts: 224 ✭✭The Mighty Dubs


    I'm not really an ASP head so I could be completely wrong here, but if you do rsInsertRQ.MoveNext after processing the SQL record it should jump to the next input value.

    No didnt work. any other ideas. This is what i tried


    <%
    Do Until iCnt = 5
    iSupplierID = rsInsertRQ.fields.item("SupplierID").value
    sdescription = rsInsertRQ.fields.item("Description").value
    sGroupcode = rsInsertRQ.fields.item("GroupCode").value
    sCollectLocation = rsInsertRQ.fields.item("CollectLocation").value
    sPackSpecs = rsInsertRQ.fields.item("PackingSpecs").value
    sSalesMail = rsInsertRQ.fields.item("SaleseMail").value
    sDesc1 = rsInsertRQ.fields.item("Desc1").value
    sImageling = rsInsertRQ.fields.item("Imagelink").value
    sValidTill = rsInsertRQ.fields.item("ValidTill").value
    dCurrency = rsInsertRQ.fields.item("Currency").value


    iQty = rsInsertRQ.fields.item("Qty").value
    iRangeA = rsInsertRQ.fields.item("RangeA").value
    iRangeB = rsInsertRQ.fields.item("RangeB").value
    iCost = rsInsertRQ.fields.item("Cost").value
    iMargin = rsInsertRQ.fields.item("Margin").value

    sSQL = "INSERT INTO TblRapidQuote(Supplierid,Description,Groupcode,COLLECTLOCATION,PackingSpecs,salesemail,Desc1,imagelink,validtill,Currency,Qty,RangeA,RangeB,Cost,margin)" & _
    " Values ('" & _
    iSupplierID & "','" & sdescription & "','" & sGroupcode & "','" & sCollectLocation & "','" & sPackingSpecs & "','" & sSaleseMail & "','" & sDesc1 & "','" & sImagelink & "','" & sValidTill & "','" & dCurrency & "'," & iQty & "," & iRangeA & "," & iRangeB & "," & iCost & "," & iMargin & ")"
    ExecuteCommand sSQL
    iCnt = iCnt + 1
    Loop
    %><%
    rsInsertRQ.MoveNext()
    %>


  • Advertisement
  • Closed Accounts Posts: 17,208 ✭✭✭✭aidan_walsh


    It will have to go in before the loop ends, otherwise it won't take effect until after all 5 iterations.


  • Registered Users Posts: 224 ✭✭The Mighty Dubs


    tried the following variations and still no luck.

    ExecuteCommand sSQL
    iCnt = iCnt + 1
    rsInsertRQ.MoveNext()
    Loop
    %>

    and

    ExecuteCommand sSQL
    rsInsertRQ.MoveNext()
    iCnt = iCnt + 1
    Loop
    %>


Advertisement