S
Scott A
I have a piece of VBA that just a few days ago was working
fine. It uses the after update event of an option group
to write changes to another table.
I am now getting an error stating that the item is not
found in the collection, when I'm sure it is (or at least
was) there!!!
Here's the code...
Private Sub optStatus_AfterUpdate()
Dim db As DAO.Database
Dim rstSOPHistory As DAO.Recordset
On Error GoTo Err_optStatus_AfterUpdate
'Determine whether user would like to record updates
using vbYesNo dialog
If MsgBox("Would you like to update the status of this
SOP in the SOP History?", _
vbYesNo, "Add to SOP History") = vbYes Then
Set db = CurrentDb()
'Open tblSOPHistory dynaset
Set rstSOPHistory = db.OpenRecordset
("tblSOPHistory", dbOpenDynaset, dbAppendOnly)
'Collect data from current form and map to fields
in dynaset***
With rstSOPHistory
.AddNew
![SOPHistID] = Me!SOPID
![SOPHistCode] = Me!SOPCode
![SOPHistTitle] = Me!SOPTitle
![SOPHistVersion] = Me!SOPVersion
![SOPHistStatus] = Me!SOPStatus
![HistDate] = Date
rstSOPHistory.Update
End With
rstSOPHistory.Close
Else: Exit Sub
End If
Exit_Err_optStatus_AfterUpdate:
Exit Sub
Err_optStatus_AfterUpdate:
MsgBox Err.Description
Resume Exit_Err_optStatus_AfterUpdate
***This is where the code falls appart when stepping
through each line. It is grabbing all of the values I
want it to with the Me!Field-s, but when I mouse over the !
[tblSOPHistoryfields], it says <Item not found in this
collcetion.>
Am I not identifying the table correctly in the recordset
declaration? I'm not sure how this was working before and
is not now...
Help?
Scott
fine. It uses the after update event of an option group
to write changes to another table.
I am now getting an error stating that the item is not
found in the collection, when I'm sure it is (or at least
was) there!!!
Here's the code...
Private Sub optStatus_AfterUpdate()
Dim db As DAO.Database
Dim rstSOPHistory As DAO.Recordset
On Error GoTo Err_optStatus_AfterUpdate
'Determine whether user would like to record updates
using vbYesNo dialog
If MsgBox("Would you like to update the status of this
SOP in the SOP History?", _
vbYesNo, "Add to SOP History") = vbYes Then
Set db = CurrentDb()
'Open tblSOPHistory dynaset
Set rstSOPHistory = db.OpenRecordset
("tblSOPHistory", dbOpenDynaset, dbAppendOnly)
'Collect data from current form and map to fields
in dynaset***
With rstSOPHistory
.AddNew
![SOPHistID] = Me!SOPID
![SOPHistCode] = Me!SOPCode
![SOPHistTitle] = Me!SOPTitle
![SOPHistVersion] = Me!SOPVersion
![SOPHistStatus] = Me!SOPStatus
![HistDate] = Date
rstSOPHistory.Update
End With
rstSOPHistory.Close
Else: Exit Sub
End If
Exit_Err_optStatus_AfterUpdate:
Exit Sub
Err_optStatus_AfterUpdate:
MsgBox Err.Description
Resume Exit_Err_optStatus_AfterUpdate
***This is where the code falls appart when stepping
through each line. It is grabbing all of the values I
want it to with the Me!Field-s, but when I mouse over the !
[tblSOPHistoryfields], it says <Item not found in this
collcetion.>
Am I not identifying the table correctly in the recordset
declaration? I'm not sure how this was working before and
is not now...
Help?
Scott