[AccessD] Setting object recordset causes loss of focus on source control

Ryan W wrwehler at gmail.com
Sun Apr 25 20:00:24 CDT 2021


I've been tinkering with ADO and recordsets, because why not.

My form has a ListBox on the left hand side, it's a selection index. When
the index_afterupdate is called, I re-bind the new filtered recordset to
the form and the combo boxes data changes to my listboxes selected item...
pretty straight forward, right?

Here's where it got weird:

The listbox somehow loses focus!  If I change the form to use a
RECORDSOURCE rather than a recordset the listbox doesn't lose focus and
up/down still work. I tried the obvious index.setfocus,
refresh/requery/repaint and nothing fixed it.

ONLY When setting the form recordset via VBA does this happen.  If I
instead move the other form objects to a subform, the problem vanishes as
well.  So it seems to have something to do with objects being in the same
form?

I did some googling and actually found someone else has encountered it and
there's a neat workaround in bottom part of the thread here:

https://social.msdn.microsoft.com/Forums/sqlserver/en-US/7e39c69c-b95e-4bc0-91e4-f8a0e11becd2/loosing-cursor-on-form-after-set-merecordset-rs?forum=accessdev


Anyway, I found it curious but also wanted to see if anyone with O365 or
Office 2016/2019 can tell me if this has been fixed or if they can still
reproduce it?


More information about the AccessD mailing list