Solved Filter sub-form via main form (1 Viewer)

Kayleigh

Member
Local time
Today, 21:21
Joined
Sep 24, 2020
Messages
706
Okay can't believe I'm already posting another query! This time I really did try to find the answer before posting it here...

So I have a pop-out unbound form which contains a bound continuous subform based on tblStudents. Here is where it gets tricky...
When user has selected which records they would like, this is committed to another table.
Now I would like to filter the form so it only shows records relevant to the previous form (frmSession), so this can be done through query or possibly the join table. However when I try adding filter to the argument of OpenForm cmd in VBA it runs into error stating it can't filter an unbound form.

So what is best way to apply filter?
 

Uncle Gizmo

Nifty Access Guy
Staff member
Local time
Today, 21:21
Joined
Jul 9, 2003
Messages
16,280
I noticed your question has not yet received a reply, hence I am bumping it up the list so that it gets another view.
 

MajP

You've got your good things, and you've got mine.
Local time
Today, 16:21
Joined
May 21, 2018
Messages
8,527
I believe this is answered already, but it could be done differently than I showed.

Your popup could be bound to sessions with the subform of student for that session. You put no fields in the main form. Get rid of record selectors and navigation buttons on main form. Although it is bound it will just look like a list of students.

Now use a criteria to open the form. The main form will move to the correct session ID and show the correct students for the session.
"SessionID = " & me.sessionID
 

gemma-the-husky

Super Moderator
Staff member
Local time
Today, 21:21
Joined
Sep 12, 2006
Messages
15,652
have a field (invisible if you want once it's working) in the unbound form.
Manually set the form - subform link to use that field

now, when you pick a new value, you just need to do something like this (in code) - but make sure the syntax is correct.
forms!controlform!controlfield = newvalue

this should set the link field in the container form, which should automatically present the subform data you want.
You should be able to do a lot with little code, if you let the data work for you.

Again similar to what @MajP said.
 

MajP

You've got your good things, and you've got mine.
Local time
Today, 16:21
Joined
May 21, 2018
Messages
8,527
Actually that is a better way than I suggested since the form is "lighter". You are not binding it. The only issue is if you need this Acdialog, which I believe you do based on how it is used then you will have to use openargs to pass in the value.
 

Users who are viewing this thread

Top Bottom