H
Hootyman
Gday, I'm getting an error " operation is not allowed when object is open"
I'm not sure which object the error is referring to. Can you have more than 1
recordset open at a time?
Dim rsAllClients As New ADODB.Recordset
Dim strSql As String
'returns all account info for a specific client
Dim rsClientAccount As New ADODB.Recordset
'retrurns the latest balance for a specific client
Dim rsClientBal As New ADODB.Recordset
Dim strLatestBal As String
'record count of clients for a trading period
Dim rCount As Integer
'
Dim Cnumber As String
rCount = 0
strSql = "SELECT Header.ClientNumber FROM Header WHERE
(((Header.ClientApp)=True) AND" & _
"((Header.[Date Allocated])<= #" & period1Date & "#));"
rsAllClients.Open strSql, CurrentProject.Connection
Do While Not rsAllClients.EOF
Debug.Print rsAllClients!ClientNumber;
rsAllClients.MoveNext
rCount = rCount + 1
Debug.Print rCount
Loop
'walk through the list of clients for the trading period and add latest
balance to latestBalanceTotal
rsAllClients.MoveFirst
Do While Not rsAllClients.EOF
strLatestBal = "SELECT Accounts.balance, Accounts.transactionDate FROM
Accounts " & _
"WHERE Accounts.ClientNumber = '" & rsAllClients!ClientNumber & "' ORDER
BY Accounts.transactionDate DESC;"
Debug.Print Cnumber
'rsClientBal.ActiveConnection = Nothing
rsClientBal.Open strLatestBal, CurrentProject.Connection
rsAllClients.MoveNext
Loop
rsAllClients.Close
Set rsAllClients = Nothing
I'm not sure which object the error is referring to. Can you have more than 1
recordset open at a time?
Dim rsAllClients As New ADODB.Recordset
Dim strSql As String
'returns all account info for a specific client
Dim rsClientAccount As New ADODB.Recordset
'retrurns the latest balance for a specific client
Dim rsClientBal As New ADODB.Recordset
Dim strLatestBal As String
'record count of clients for a trading period
Dim rCount As Integer
'
Dim Cnumber As String
rCount = 0
strSql = "SELECT Header.ClientNumber FROM Header WHERE
(((Header.ClientApp)=True) AND" & _
"((Header.[Date Allocated])<= #" & period1Date & "#));"
rsAllClients.Open strSql, CurrentProject.Connection
Do While Not rsAllClients.EOF
Debug.Print rsAllClients!ClientNumber;
rsAllClients.MoveNext
rCount = rCount + 1
Debug.Print rCount
Loop
'walk through the list of clients for the trading period and add latest
balance to latestBalanceTotal
rsAllClients.MoveFirst
Do While Not rsAllClients.EOF
strLatestBal = "SELECT Accounts.balance, Accounts.transactionDate FROM
Accounts " & _
"WHERE Accounts.ClientNumber = '" & rsAllClients!ClientNumber & "' ORDER
BY Accounts.transactionDate DESC;"
Debug.Print Cnumber
'rsClientBal.ActiveConnection = Nothing
rsClientBal.Open strLatestBal, CurrentProject.Connection
rsAllClients.MoveNext
Loop
rsAllClients.Close
Set rsAllClients = Nothing