Hi, I'm new to ACCESS
What I am trying to do is:
I am looping the the table SIGNALS and would like to append data to the table EQUITY.
The following code is just a shell. Just to prove the logic works.
Well, it doesn't
You help is appreciated.
Public Sub trade()
'Set up the connection,
Dim cnn1 As ADODB.Connection
Set cnn1 = New ADODB.Connection
'Declare record set
Dim rst As ADODB.Recordset
Set rst = New ADODB.Recordset
Dim rst2 As ADODB.Recordset
Set rst2 = New ADODB.Recordset
Dim tradecount As Integer
rst.LockType = adLockOptimistic
rst.ActiveConnection = CurrentProject.Connection
rst.Open "select * from signals"
' loop thru the rst SIGNALS until you reach the end of the file
Do Until rst.EOF
' increment the counter
tradecount = tradecount + 1
' Add a row of data to rst2 EQUITY TABLE
With rst2
.ActiveConnection = CurrentProject.Connection
.CursorType = adOpenKeyset
.LockType = adLockOptimistic
.Open "select * from equity where id = 0 "
.AddNew
!id = tradecount
.Update
End With
rst.MoveNext
Loop
End Sub
What I am trying to do is:
I am looping the the table SIGNALS and would like to append data to the table EQUITY.
The following code is just a shell. Just to prove the logic works.
Well, it doesn't
You help is appreciated.
Public Sub trade()
'Set up the connection,
Dim cnn1 As ADODB.Connection
Set cnn1 = New ADODB.Connection
'Declare record set
Dim rst As ADODB.Recordset
Set rst = New ADODB.Recordset
Dim rst2 As ADODB.Recordset
Set rst2 = New ADODB.Recordset
Dim tradecount As Integer
rst.LockType = adLockOptimistic
rst.ActiveConnection = CurrentProject.Connection
rst.Open "select * from signals"
' loop thru the rst SIGNALS until you reach the end of the file
Do Until rst.EOF
' increment the counter
tradecount = tradecount + 1
' Add a row of data to rst2 EQUITY TABLE
With rst2
.ActiveConnection = CurrentProject.Connection
.CursorType = adOpenKeyset
.LockType = adLockOptimistic
.Open "select * from equity where id = 0 "
.AddNew
!id = tradecount
.Update
End With
rst.MoveNext
Loop
End Sub