Tra71
asked on
Insert number of rows depending on value in quantity
Hi,
I need to insert records from one table to another depending on what the value is the Quantity field.
At the moment, it's only inserting one record for each line. I would like to, if there is a value of more than one in the Quantity field, insert that number of rows.
Below is the code so far.
Many thanks :)
strSQL = "SELECT * FROM [Job Quotes Details] WHERE [SubID] = '" & nParentID & "';"
objRS.Open strSQL, objConn
If Not objRS.EOF Then
Do Until objRS.EOF
strSQL = "INSERT INTO [Job Cost Sheets Details] ([Item],[Quantity],[Days], [Unit Price], Total, SubID) SELECT '"
strSQL = strSQL & Replace(objRS("Item"), "'", "''") & "', " & objRS("Quantity") & ", " & objRS("Days") & ", " & objRS("Unit Price") & ", "
strSQL = strSQL & objRS("Total") & ", " & nID & ";"
objRS2.Open strSQL, objConn
objRS.MoveNext
Loop
End If
objRS.Close
I need to insert records from one table to another depending on what the value is the Quantity field.
At the moment, it's only inserting one record for each line. I would like to, if there is a value of more than one in the Quantity field, insert that number of rows.
Below is the code so far.
Many thanks :)
strSQL = "SELECT * FROM [Job Quotes Details] WHERE [SubID] = '" & nParentID & "';"
objRS.Open strSQL, objConn
If Not objRS.EOF Then
Do Until objRS.EOF
strSQL = "INSERT INTO [Job Cost Sheets Details] ([Item],[Quantity],[Days],
strSQL = strSQL & Replace(objRS("Item"), "'", "''") & "', " & objRS("Quantity") & ", " & objRS("Days") & ", " & objRS("Unit Price") & ", "
strSQL = strSQL & objRS("Total") & ", " & nID & ";"
objRS2.Open strSQL, objConn
objRS.MoveNext
Loop
End If
objRS.Close
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER