Forums

ASP

This topic is locked

Insert Form loop question

Posted 01 Oct 2008 19:07:04
1
has voted
01 Oct 2008 19:07:04 greg dillon posted:
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
%>

Replies

Replied 14 Oct 2008 17:32:10
14 Oct 2008 17:32:10 Glenn Barr replied:
Try adding:

rsInsertRQ.MoveNext

before the Loop statement at the end. Otherwise, you're showing the same record as the previous time.

HTH

<BLOCKQUOTE id=quote><font size=1 face="Verdana, Arial, Helvetica" id=quote>quote:<hr height=1 noshade id=quote>
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?

******************
&lt;%
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
%&gt;
<hr height=1 noshade id=quote></BLOCKQUOTE id=quote></font id=quote><font face="Verdana, Arial, Helvetica" size=2 id=quote>
Replied 16 Oct 2008 17:49:20
16 Oct 2008 17:49:20 greg dillon replied:
Fixed this, so just in case anyone was wondering how this is what i did

*************************************************************

&lt;%

If request.Form("Submit"="Submit" then
iCnt=1
Do Until iCnt = 6
iSupplierID = request.Form("Supplierid"
sdescription = request.form("Description"
sGroupcode = request.form("GroupCode"
sROHSAPPROVED = request.form("ROHSAPPROVED"
sWEEEAPPLICABLE = request.form("WEEEAPPLICABLE"
sCEAPPROVED = request.form("CEAPPROVED"
sINCOTERMS = request.form("INCOTERMS"
sFOB = request.form("FOB"
sCIF = request.form("CIF"
sExWorks = request.form("ExWorks"
sCollectLocation = request.form("CollectLocation"
sPackingSpecs = request.form("PackingSpecs"
isalesemail = request.form("salesemail"
sDesc1 = request.form("Desc1"
sImagelink = request.form("Imagelink"
sValidTill = request.form("ValidTill"
dCurrency = request.form("Currency"

iQty = request.form("Qty" & iCnt)
iRangeA = request.form("RangeA" & iCnt)
iRangeB = request.form("RangeB" & iCnt)
iCost = request.form("Cost" & iCnt)
iMargin = request.form("Margin" & iCnt)

If Request.Form("Qty" & iCnt) &lt;&gt; "" Then
sSQL = "INSERT INTO TblRapidQuote(Supplierid,Description,Groupcode,ROHSAPPROVED,WEEEAPPLICABLE,CEAPPROVED,INCOTERMS,FOB,CIF,ExWorks,COLLECTLOCATION,PackingSpecs,salesemail,Desc1,imagelink,validtill,Currency,Qty,RangeA,RangeB,Cost,margin)" & _
" Values ('" & _
iSupplierID & "','" & sdescription & "','" & sGroupcode & "','" & sROHSAPPROVED & "','" & sWEEEAPPLICABLE & "','" & sCEAPPROVED & "','" & sINCOTERMS & "','" & sFOB & "','" & sCIF & "','" & sExWorks & "','" & sCollectLocation & "','" & sPackingSpecs & "','" & _
isalesemail & "','" & sDesc1 & "','" & sImagelink & "','" & sValidTill & "','" & dCurrency & "'," & iQty & "," & iRangeA & "," & iRangeB & "," & iCost & "," & iMargin & ""
ExecuteCommand sSQL
End IF
iCnt = iCnt + 1

Loop
END IF

%&gt;

Reply to this topic