Method 'Recordset' of object '_Form_FisaApt' failed (run-time error 2470) (1 Viewer)

Adelina_RO

Member
Local time
Today, 15:03
Joined
Apr 9, 2021
Messages
42
Here is an interesting question.
I have a form with a subform bound to a ADO recordset. I set this like so:
Code:
Set Me.Recordset = cMED.Execute("CALL `FisaApt_C1`(0, '" & ADO_Path(CurrentProject.Path & "\PNG\") & "')")
- and it works just fine.
Then, on the parent form, i have a textbox which acts like a search box. For this, on the "AfterUpdate" event, i change the subform's recordset based on the input text, like so:
Code:
Set Rs = cMED.Execute("CALL `FisaApt_CX`('" & T & "', '" & ADO_Path(CurrentProject.Path & "\PNG\") & "')")
If Rs.RecordCount <> 0 Then Set FisaApt_Sub.Form.Recordset = Rs
- and it works just fine.
The problem is that i want to make it change the subform's recordset as the user types in numbers, so i use the "OnChange" event of the textbox to update the subform's recordset using almost the same code:
Code:
Set Rs = cMED.Execute("CALL `FisaApt_CX`('" & T.Text & "', '" & ADO_Path(CurrentProject.Path & "\PNG\") & "')")
If Rs.RecordCount <> 0 Then Set FisaApt_Sub.Form.Recordset = Rs
- this raises the error in the title of this post.
So my question is: can a form's recordset (ADO based, NOT DAO) be changed as the user types whatever he wants?
Thank you :)
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 21:03
Joined
May 7, 2009
Messages
19,175
if the end-user is a fast typist and the server is slow on getting records, this might occur.
are you not satisfied on using AfterUpdate event, there is a margin for error for
the user to backspace and the .Execute is not executed on every character he types.
 

Adelina_RO

Member
Local time
Today, 15:03
Joined
Apr 9, 2021
Messages
42
if the end-user is a fast typist and the server is slow on getting records, this might occur.
are you not satisfied on using AfterUpdate event, there is a margin for error for
the user to backspace and the .Execute is not executed on every character he types.
i've thought of that and typed in the values very slowly. actually, i have a condition that doesn't execute anything if Len(T.Text) < 5, so after the fifth character, i stop typing to test exactly this scenario. and it still doesn't work. i believe the form is somehow locked when running code in the "onchange" event, even if the event fires for the parent form, not the subform...
 

Users who are viewing this thread

Top Bottom