G
Guest
I am trying to update a table from a subform using a cmd button. This is what
I have so far. The purpose of this is to keep track of the Remaining shares
that are put in manually and I need to add this Shares to a History Table.
When I run this I get a error:
Run-Time '3625'
Item not found in this collection
Anything would be great because I hit a brick wall.
Private Sub cmdHistory_Click()
Dim dbsLocal As DAO.Database
Dim rstTable As DAO.Recordset
Dim rstForm As DAO.Recordset
Set rstForm = Me.RecordsetClone
Set dbsLocal = CurrentDb()
Set rstTable = dbsLocal.OpenRecordset("History", DB_OPEN_DYNASET)
rstForm.MoveFirst
Do Until rstForm.EOF
With rstTable
If rstForm![TradeAmount] <> 0 Then
.AddNew
.Fields("FundID") = rstForm![FundID]
.Fields("AssetDescription") = rstForm![AssetDescription]
.Fields("Ticker") = rstForm![Ticker]
.Fields("NavChkDate") = rstForm![NavChkDate]
.Fields("DateApporved") = rstForm![DateApporved]
.Fields("Shares") = rstForm![Shares]
.Fields("RemainingShares") = rstForm![RemainingShares]
.Fields("TradeAmount") = rstForm![TradeAmount]
.Update
End If
End With
rstForm.MoveNext
Loop
rstTable.Close
rstForm.Close
MsgBox " Update Complete"
End Sub
I have so far. The purpose of this is to keep track of the Remaining shares
that are put in manually and I need to add this Shares to a History Table.
When I run this I get a error:
Run-Time '3625'
Item not found in this collection
Anything would be great because I hit a brick wall.
Private Sub cmdHistory_Click()
Dim dbsLocal As DAO.Database
Dim rstTable As DAO.Recordset
Dim rstForm As DAO.Recordset
Set rstForm = Me.RecordsetClone
Set dbsLocal = CurrentDb()
Set rstTable = dbsLocal.OpenRecordset("History", DB_OPEN_DYNASET)
rstForm.MoveFirst
Do Until rstForm.EOF
With rstTable
If rstForm![TradeAmount] <> 0 Then
.AddNew
.Fields("FundID") = rstForm![FundID]
.Fields("AssetDescription") = rstForm![AssetDescription]
.Fields("Ticker") = rstForm![Ticker]
.Fields("NavChkDate") = rstForm![NavChkDate]
.Fields("DateApporved") = rstForm![DateApporved]
.Fields("Shares") = rstForm![Shares]
.Fields("RemainingShares") = rstForm![RemainingShares]
.Fields("TradeAmount") = rstForm![TradeAmount]
.Update
End If
End With
rstForm.MoveNext
Loop
rstTable.Close
rstForm.Close
MsgBox " Update Complete"
End Sub