Event for filtering based on sub-datasheet record (1 Viewer)

Kayleigh

Member
Local time
Today, 03:58
Joined
Sep 24, 2020
Messages
706
Hi,
I would like to filter a listbox based on the record selected in a sub-datasheet in the same form. However I am not certain which event would be best for this?
I could program it on the click event on a few fields in the datasheet but wondering if there is any more efficient ways would work?
 

bastanu

AWF VIP
Local time
Yesterday, 19:58
Joined
Apr 13, 2010
Messages
1,402
Why not try to do it in the Current event of the subform using the Parent object?
 

Kayleigh

Member
Local time
Today, 03:58
Joined
Sep 24, 2020
Messages
706
Okay but if I wish to clear the filter with a command button, it would probably interfere?
 

bastanu

AWF VIP
Local time
Yesterday, 19:58
Joined
Apr 13, 2010
Messages
1,402
To clear the filter you could use the double click event of the listbox itself.

Cheers,
 

Pat Hartman

Super Moderator
Staff member
Local time
Yesterday, 22:58
Joined
Feb 19, 2002
Messages
43,266
I'm confused by your structure. Is the listbox on the subform?
Is the listbox an unbound control on the parent form?
 

conception_native_0123

Well-known member
Local time
Yesterday, 21:58
Joined
Mar 13, 2021
Messages
1,834
To clear the filter you could use the double click event of the listbox itself.

Cheers,
You can use almost all events for this. I think what you want to do is just fine krayna. Furthermore, I think your question is more or less splitting hairs when you don't need to
 

bastanu

AWF VIP
Local time
Yesterday, 19:58
Joined
Apr 13, 2010
Messages
1,402
Of course you can use " almost all events" but the double-click doesn't trigger by mistake as often as most....
 

bastanu

AWF VIP
Local time
Yesterday, 19:58
Joined
Apr 13, 2010
Messages
1,402
??? of course YOU didn't, but most of us mortals did....
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 10:58
Joined
May 7, 2009
Messages
19,238
you can actually do it, if you make the "sub-datasheet" as subform (ds subform).
see this demo.
 

Attachments

  • mysubdata.accdb
    640 KB · Views: 215
Last edited:

Kayleigh

Member
Local time
Today, 03:58
Joined
Sep 24, 2020
Messages
706
Sorry @arnelgp that sample filter doesn't seem to be working for me.
I think I have a very similar layout to yours. thanks
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 10:58
Joined
May 7, 2009
Messages
19,238
i re-opened it and there is error?
i fixed it. you click on "+" to open the subdatasheet, then
you browse the subdatasheet, you will see that the listbox
is filtering.
 

Attachments

  • mysubdata.accdb
    744 KB · Views: 210

Kayleigh

Member
Local time
Today, 03:58
Joined
Sep 24, 2020
Messages
706
I see now but can this be done without a sub-datasheet ie on the main subform?
 

Users who are viewing this thread

Top Bottom