filter of a form does not work when this form is under navigation form (1 Viewer)

Ihk

Member
Local time
Today, 05:21
Joined
Apr 7, 2020
Messages
83
I have a form on which I have checkbox to filter form record.
It works perfectly fine and filters the records without any problem. Below is my code.
PROBLEM:
When I bring this form under a navigation form (button), it asks for the name of the record to enter.
FORM1
Field name: Ordertype and Field record to filter: Current
Code below works perfect.
But on FORM2 with navigation button, which opens this FORM1, when I click on this CurrentChckBox , it asks for to enter value of "OrderType" to filter, and even if I enter the value "Current", It also wont filter. I searched about this, people saying to give path of form, but I could not solve it. Thanks

Code:
  If CurrentChckBox = True Then
    DoCmd.ApplyFilter , "[Ordertype] = 'Current'"
Else
    If CurrentChckBox = False Then
    Me.FilterOn = False
      Exit Sub
    End If
  End If
 

arnelgp

once i caught a fish alive...
Local time
Today, 11:21
Joined
May 7, 2009
Messages
13,205
where is the CurrentChckBox located?

Docmd.BrowseTo acBrowseToForm, "Form1","Form2.NavigationSubform", "[Ordertype] ='Current'"
 
  • Like
Reactions: Ihk

CJ_London

Super Moderator
Staff member
Local time
Today, 04:21
Joined
Feb 19, 2013
Messages
13,093
You are only showing part of the code and when you say form 2 opens form1, is this as a subform or a separate form?

your code does not have anything that asks for order type.

and where is the code? I’m assuming form 1 because you say it works if you don’t use the navigation form

next - what is the data type for you order type field? Code assumes text, but most developers would be using a number and description using a drop down on the form - if you have it in the table then perhaps this is the issue

most developers don’t use navigation forms because of their limitations and maybe this is one of them
 

Ihk

Member
Local time
Today, 05:21
Joined
Apr 7, 2020
Messages
83
where is the CurrentChckBox located?

Docmd.BrowseTo acBrowseToForm, "Form1","Form2.NavigationSubform", "[Ordertype] ='Current'"
Thank you very much, I tried this. And it worked. But Now how to cancel the event, if CurrentChkBox is unchecked (meaning False), earlier in my code was Me.FilterOn = False
But I dont have experience with BrowseTo. Thank you again.

This Check box is located on the main FORM1 (which displays record).
 

Ihk

Member
Local time
Today, 05:21
Joined
Apr 7, 2020
Messages
83
You are only showing part of the code and when you say form 2 opens form1, is this as a subform or a separate form?

your code does not have anything that asks for order type.

and where is the code? I’m assuming form 1 because you say it works if you don’t use the navigation form

next - what is the data type for you order type field? Code assumes text, but most developers would be using a number and description using a drop down on the form - if you have it in the table then perhaps this is the issue

most developers don’t use navigation forms because of their limitations and maybe this is one of them
Thank you very much for your reply.
1) Main form (FORM1) which displays data, has check box. No subform on it
2) This forms filters well on its own perfectly,
3) When I open this form on another form (FORM2) which has many navigation buttions. There this FORM1 having check box on it, has problem in filtering as explained above.
4) Yes you are right, Field on (FORM1) to be filtered contains Combo box (which also includes record "Current"), but I want to filter the record by check box on FORM1 but not by combo box. Otherwise Combo Boxes filteration on other forms working perfectly fine with subforms on those. But never tried this option on Navigation forms...
Thank you
 

arnelgp

once i caught a fish alive...
Local time
Today, 11:21
Joined
May 7, 2009
Messages
13,205
you BrowseTo without Criteria:

Docmd.BrowseTo acBrowseToForm, "Form1","Form2.NavigationSubform"
 

Pat Hartman

Super Moderator
Staff member
Local time
Yesterday, 23:21
Joined
Feb 19, 2002
Messages
32,225
Once you put your form on a navigation form, it is no longer a main form. It becomes a subform. Since most of my BE's are SQL Server, I NEVER use filters so this isn't my area of expertise but I thought that filters either don't work or work differently on subforms.
 

Users who are viewing this thread

Top Bottom