Solved Update the Filter of a Subform of a Subform (1 Viewer)

Saphirah

Member
Local time
Today, 04:03
Joined
Apr 5, 2020
Messages
92
Hey everyone,

for our software i want to create a form showing all customers in a table-view.
In addition to that a subdatasheet is supposed to show all orders related to the customer.

For this i created a subform, that shows all customers in table-view, and another subform inside the subform which shows all orders in table view.
This will result in a subdatasheet. See screenshot attached
1619691796379.png


Now i want to create a filter option, where you can use a date "from-to" input to show orders only in a specific date.
But if i try to add a filter to the sub-sub-datasheet i get the following error:
Code:
access error 2455 invalid reference to the property form report

The code i am trying to execute is the following:
Code:
Me.frm_Zahlungen_Sub.Form.SubdataForm.Form.Filter = strFilter

When trying to access the SubSubForm by the following code
Code:
Forms("SubdataForm").Form.Filter = strFilter
I get the Error
Code:
access error 2450 cannot find the referenced form
this usually happens when the form is not open.
I made sure that there is no typo in the name, or the code. So probably the Form can not be accessed if it is functioning as a subdatasheet.

So, how can i set the filter in the described case? Thank you very much!
 
Last edited:

arnelgp

error reading drive A:
Local time
Today, 10:03
Joined
May 7, 2009
Messages
12,825
With Forms!theMainForm!frm_Zahlungen_Sub!SubdataForm.Form
.Filter = strFilter
.FilterOn = True
End With
 

Saphirah

Member
Local time
Today, 04:03
Joined
Apr 5, 2020
Messages
92
With Forms!theMainForm!frm_Zahlungen_Sub!SubdataForm.Form
.Filter = strFilter
.FilterOn = True
End With
i tried the following code
Code:
With Forms!frm_Zahlungen!frm_Zahlungen_Sub!SubdataForm.Form
    .Filter = strFilter
    .FilterOn = True
End With

But i still get the error on the first line
Code:
access error 2455 invalid reference to the property form report
 

Saphirah

Member
Local time
Today, 04:03
Joined
Apr 5, 2020
Messages
92
1619694402293.png


1619694437149.png


Both names are correct though, so what may be the problem here?
 

MajP

You've got your good things, and you've got mine.
Local time
Yesterday, 22:03
Joined
May 21, 2018
Messages
5,037
After the name of each subform control add
.Form
 

Saphirah

Member
Local time
Today, 04:03
Joined
Apr 5, 2020
Messages
92
After the name of each subform control add
.Form
That is what i originally did. See my first post :) I tried it with the new "With" code
Code:
With Forms!frm_Zahlungen!frm_Zahlungen_Sub.Form!SubdataForm.Form
Still get the same error
 

Saphirah

Member
Local time
Today, 04:03
Joined
Apr 5, 2020
Messages
92
I think the problem here is that a SubSubForm opened as a Subdatasheet can not be referenced? But how do i get my code to work? Is there another way to reference it?
 

Pat Hartman

Super Moderator
Staff member
Local time
Yesterday, 22:03
Joined
Feb 19, 2002
Messages
31,957
Rather than using a filter, change the RecordSource of the subsubform to a query with criteria that references the subform.
 

MajP

You've got your good things, and you've got mine.
Local time
Yesterday, 22:03
Joined
May 21, 2018
Messages
5,037
I do not know where your issue is, you could post the DB. The following is wrong.
I think the problem here is that a SubSubForm opened as a Subdatasheet can not be referenced?
Of course you can.
 

Saphirah

Member
Local time
Today, 04:03
Joined
Apr 5, 2020
Messages
92
Here is the database. I can not give you the tables because they have customer data in it. I Removed the recordsource in the form, so the code should work.
The error appears in the following line:
Code:
With Forms!frm_Zahlungen.Form!frm_Zahlungen_Sub.Form!SubdataForm.Form
 

Attachments

  • Database1.accdb
    640 KB · Views: 18

arnelgp

error reading drive A:
Local time
Today, 10:03
Joined
May 7, 2009
Messages
12,825
see the code on the Filter button.
 

Attachments

  • Database1.accdb
    808 KB · Views: 21

Saphirah

Member
Local time
Today, 04:03
Joined
Apr 5, 2020
Messages
92
see the code on the Filter button.
Thank you arnelgp, your code helped me. You did convert the datasheet form to a single form view though, so this kinda defeats the purpose of my form. The error still persists when you convert it to a datasheet view and close all subdatasheets.

I think the problem lies somewhere else. When you are in datasheet view and you have subdatasheets on the form that are not expanded, these subdatasheets do not exist for access. So as long as you do not expand a subdatasheet the underlying form is not opened and can not be filtered. I will mark the thread as solved, because this is a problem with access. I might come back when i find a solution...
 

arnelgp

error reading drive A:
Local time
Today, 10:03
Joined
May 7, 2009
Messages
12,825
see form1.
 

Attachments

  • Database1.accdb
    1.3 MB · Views: 20

Users who are viewing this thread

Top Bottom