Filtering a Subform (1 Viewer)

andy1968

Registered User.
Local time
Yesterday, 16:13
Joined
May 9, 2018
Messages
131
Help.


I am certain this is easy, and I just have a syntax error.


I have a subform that I'd like to filter with a command button.


The subform has a calculated field txtOpen with the value:


=IIf(IsNull([DateToContractor]),"Open","Closed")


I am trying the following code, with no luck.


Private Sub cmdOpenOnly_Click()
Me.frmRFIListSubForm.Form.Filter = "txtOpen='Open'"
Me.frmRFIListSubForm.Form.FilterOn = True
End Sub
 

Mark_

Longboard on the internet
Local time
Yesterday, 16:13
Joined
Sep 12, 2017
Messages
2,111
Two questions;
First, does the subform show "Open" and "Closed" properly?
Second, on which form (parent or child) is the button located?
 

andy1968

Registered User.
Local time
Yesterday, 16:13
Joined
May 9, 2018
Messages
131
Yes, Open and Close show properly.


The button is on the parent form.


Attached is a screen shot.
 

Attachments

  • Capture.JPG
    Capture.JPG
    55.2 KB · Views: 33

andy1968

Registered User.
Local time
Yesterday, 16:13
Joined
May 9, 2018
Messages
131
I don't get an error, however a window pops up Titled "Enter Parameter Value"


I'll attach a screen shot of it.
 

Attachments

  • Capture.JPG
    Capture.JPG
    74.5 KB · Views: 29

andy1968

Registered User.
Local time
Yesterday, 16:13
Joined
May 9, 2018
Messages
131
Here is a portion of my database with the problem form.
 

Attachments

  • rfi.zip
    63.3 KB · Views: 35

Mark_

Longboard on the internet
Local time
Yesterday, 16:13
Joined
Sep 12, 2017
Messages
2,111
You really don't want to filter on the calculated field, you want to filter based on the database field [DateToContractor].

Your filter should be something like
InNull(DateToContractor)

I'd take a look at this thread for a few more ideas.
 

andy1968

Registered User.
Local time
Yesterday, 16:13
Joined
May 9, 2018
Messages
131
Thanks!


I modified the code as such and got it to work.


Me.frmRFIListSubForm.Form.Filter = "IsNull(DateToContractor) = True"
Me.frmRFIListSubForm.Form.FilterOn = True
 
Last edited:

Users who are viewing this thread

Top Bottom