|
BeTheBall -> RE: help with a form (6/24/2004 15:32:36)
|
Actually that is quite similar to what I posted. You need a distinct form field name for the name and shift number but no the date. I have a form that does exactly the same thing. The date is the same for each record but the other data changes. Here is the code that processes the form: <% DIM conntemp, mySQL, myDSN
myDSN ="Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.Mappath("\pps\Team304\fpdb\Review304.mdb")
set conntemp=server.createobject("adodb.connection")
conntemp.open myDSN
FOR i = 1 to 15
IF Request("AspectNumber" & i) <> "" THEN
mySQL = "INSERT INTO AHT (ADate, Application, Aspect, Calls, Talk, Hold, Wrap) VALUES"
mySQL = mySQL & " (#" & Request("ADate") & "#, " & Request("Application") & ", " & Request("AspectNumber" & i) & ", " & Request("Calls" & i) & ", " & Request("Talk" & i) & ", " & Request("Hold" & i) & ", " & Request("Wrap" & i) & ")"
conntemp.execute(mySQL)
END IF
NEXT
conntemp.close
set conntemp=nothing
Response.write "Record added."
%> Notice how in the SQL, the field ADate and Application are not followed by "& i". That is because there is only one form field for ADate and Application. However, there are multiple form fields for AspectNumber, Calls, etc. Hence, the additions of "&i". The code loops through the form fields beginning with AspectNumber1 and inserts a record for each AspectNumber on the form. The key to making the whole thing work is having distinct form field names for each repeating item. For example, you are going to have 125 names so you want the form fields to be Name1, Name2, Name3, etc. That will allow the code to loop through and insert a new record for each Name field. Does that make any more sense?
|
|
|
|