Dave Eyley
Registered User.
- Local time
- Today, 15:24
- Joined
- Sep 5, 2002
- Messages
- 254
I've found what seems to be a problem.
I have a form on which a user can use an unbound Combo box to select an item from the list.
I don't use the 'Not in List' facility - instead I wrote a short piece of code that compares the entry with the table to see if it exists already and if not, it asks the user if it should be added, if the response is in the affirmative then the routine adds the item to the table and requeries the combo Rowsource.
It works most of the time....there doesn't appear to be any problem with the code. But randomly and about 20% of the time, the routing stops with an error message. 3420 - Object invalid or no longer set...
the code in question is -
COMBO - AFTERUPDATE
Dim MyDbX As Database, MySetX As Recordset, Flag As Integer
Set MyDbX = DBEngine.Workspaces(0).Databases(0)
Set MySetX = MyDbX.OpenRecordset("ItemList")
MySetX.MoveFirst
Do Until MySetX.EOF
If MySetX![ItemDesc] = Me!ItemDesc Then Flag = 1
MySetX.MoveNext
Loop
If Flag = 0 Then
Dim MyReply As Integer
MyReply = MsgBox("This Item is not in the stored list." & Chr$(10) & Chr$(10) & "Do You want to add it?", vbYesNo, "New Item?")
If MyReply = 7 Then
Me!ItemDesc = Null
MySetX.Close
MyDbX.Close
Else
MySetX.AddNew
MySetX![ItemDesc] = Me!ItemDesc
MySetX.Update
MySetX.Close
MyDbX.Close
Forms!LostNew!ItemDesc.Requery
MsgBox "New Item added", vbInformation, "Confirmed Addition"
End If
End If
This is bugging me - as it works some of the time with no external changes apparent.
Can't even blame a network for this one....it's stand-alone
Dave E
I have a form on which a user can use an unbound Combo box to select an item from the list.
I don't use the 'Not in List' facility - instead I wrote a short piece of code that compares the entry with the table to see if it exists already and if not, it asks the user if it should be added, if the response is in the affirmative then the routine adds the item to the table and requeries the combo Rowsource.
It works most of the time....there doesn't appear to be any problem with the code. But randomly and about 20% of the time, the routing stops with an error message. 3420 - Object invalid or no longer set...
the code in question is -
COMBO - AFTERUPDATE
Dim MyDbX As Database, MySetX As Recordset, Flag As Integer
Set MyDbX = DBEngine.Workspaces(0).Databases(0)
Set MySetX = MyDbX.OpenRecordset("ItemList")
MySetX.MoveFirst
Do Until MySetX.EOF
If MySetX![ItemDesc] = Me!ItemDesc Then Flag = 1
MySetX.MoveNext
Loop
If Flag = 0 Then
Dim MyReply As Integer
MyReply = MsgBox("This Item is not in the stored list." & Chr$(10) & Chr$(10) & "Do You want to add it?", vbYesNo, "New Item?")
If MyReply = 7 Then
Me!ItemDesc = Null
MySetX.Close
MyDbX.Close
Else
MySetX.AddNew
MySetX![ItemDesc] = Me!ItemDesc
MySetX.Update
MySetX.Close
MyDbX.Close
Forms!LostNew!ItemDesc.Requery
MsgBox "New Item added", vbInformation, "Confirmed Addition"
End If
End If
This is bugging me - as it works some of the time with no external changes apparent.
Can't even blame a network for this one....it's stand-alone
Dave E
Last edited: