|
-
Jul 5th, 2005, 03:48 PM
#1
Thread Starter
Lively Member
[RESOLVED] Multiple Record set in one execute
Looking for information on how to place two select statement within a loop
The first is to look up the balence for each customer then the second is to insert that balance into another row in a another table...
I have this though the second Select Statement is still connected so I can not rs.movenext from the first select statement...
Let me know what you think, Thank you
Code Snippet
##################################################
Private Sub RUNBATCH()
conn.Open sConnString
Set cmd.ActiveConnection = conn
'SELECT STATEMENT
cmd.CommandText = "SELECT BatchID, CustID, Balance " & _
" From CUSTBAL" 'WHERE CustID = '" & Val(txtCustID.Text) & "'"
cmd.CommandType = adCmdText
Set rs = cmd.Execute
Do Until rs.EOF
[INDENT]strIBatchID = rs!BatchID
[INDENT]strICustID = rs!CustID
strIBal = rs!Balance
'INSERT VALUES FROM FIRST SELCT STATEMENT - CURRENT RECORD
cmd.CommandText = "INSERT INTO TBLINVOICE (BID, CID, TOTBILL)" & _
" VALUES (" & Val(strIBatchID) & " , " & Val(strICustID) & " , " & Val(strIBal) & ")"
'EXECUTES SECOND INSERT STATEMENT
cmd.CommandType = adCmdText
Set rs = cmd.Execute
'MOVE TO NEXT RECORD - NEEDS TO BE FROM FIRST STATEMENT
rs.MoveNext
'LOOPS
Loop
'CLEARS
Set rs = Nothing
Set cmd = Nothing
conn.Close
Set conn = Nothing
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|