Aeristan
Registered User.
- Local time
- Yesterday, 23:53
- Joined
- Mar 29, 2019
- Messages
- 33
Advised to change to the followingCode:Me.Recordset.FindFirst ("[Name] = ""Raven"" ")
Code:Me.Recordset.FindFirst "[Name] = " & chr(34) & "Raven" & chr(34)
Access will accept either syntax and the error occurs either way.
To test the last, from my immediate window, the result as follows:
Code:? "[Name] = " & chr(34) & "Raven" & chr(34) [Name] = "Raven"
That is the result that I get as well.
Maybe this will shed more light. Each one of my event handlers contains a Debug.Print statement, to help me manage the flow of the code. Here is what I see in my Immediate window when I enter Form view:
Code:
=== BEGIN AccessMUD ==================================================
subform_INVENTORY: form Open event context: subform_INVENTORY
subform_INVENTORY: form Current event ( Item.Name = Periwinkle Princess Dress, Item.ID = 1 ) context: subform_INVENTORY
form_CHARACTER: form Open event ( Character = 4 "Sarjenka" )
TypeName(Me.Recordset) = Recordset2 Me.Recordset.Name = CHARACTER
calling Me.Recordset.FindFirst ( Name = "Raven" ) from context: form_CHARACTER
form_CHARACTER: form Load event ( Character = 5 "Raven" )
form_CHARACTER: form Current event ( Character = 5 "Raven" )
subform_INVENTORY: form Current event ( Item.Name = Panther-hide armor, Item.ID = 3 ) context: subform_INVENTORY
form_CHARACTER: combo_ID Change event ( Character = 5 'Raven' ) Now = 4/20/2019 12:47:23 PM
TypeName(Me.Recordset) = Recordset2 Me.Recordset.Name = CHARACTER
calling Me.Recordset.FindFirst ( [ID] = 4 ) from context: form_CHARACTER
form_CHARACTER: form Current event ( Character = 4 "Sarjenka" )
subform_INVENTORY: form Current event ( Item.Name = Periwinkle Princess Dress, Item.ID = 1 ) context: subform_INVENTORY
--> Error in Sub combo_ID_Change: Method 'FindFirst' of object 'Recordset2' failed (number -2147417848)
TypeName(Me.Recordset) = Recordset2 param = "[ID] = 4"
So what you are seeing happen is this: the Form_Open event is called, the FindFirst method is invoked, the error in question does not occur, and the desired record is displayed. Then, I use the combo_ID control, which also uses the FindFirst method (except that it finds based on ID rather than Name). This time, the error does appear.
But it doesn't always happen like this. Sometimes the error occurs immediately in the Form_Open event, and other times, I can navigate records several times before it fires.
Yet even when the error does occur, the FindFirst method apparently still does its thing, because the new record is displayed on the Form afterwards. With an error handler that ignores it, the only way I would know it was going on would be the Immediate window.
Last edited: