ApplyFilter command not working on a subform

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I'm trying to apply the following via a command button on a subform. When I
click the command button when the form is not opened as a subform (F11 and
opening the form directly) all works fine. However, when I open my main form
(frmTabOpportunity) which contains my subform (frmTask) the command button on
the subform no longer works.

DoCmd.ApplyFilter , "closed=no"

Any suggestions?
 
Assign the string to the Filter property of the subform, and toggle FilterOn
as well:

With Me.[NameOfYourSubformHere].Form
.Filter = "closed=no"
.FilterOn = True
End With

If you apply a filter to both the main form and the subform, Access can get
confused. Details in:
Incorrect filtering of forms and reports
at:
http://allenbrowne.com/bug-02.html
This bug has been fixed in Access 2007, but still applies to Access 95, 97,
2000, 2002, and 2003.
 
I get a "method or data member not found" error. I'm assuming the first line
literally should be

With Me.frmTask.Form

Is that correct?

Allen Browne said:
Assign the string to the Filter property of the subform, and toggle FilterOn
as well:

With Me.[NameOfYourSubformHere].Form
.Filter = "closed=no"
.FilterOn = True
End With

If you apply a filter to both the main form and the subform, Access can get
confused. Details in:
Incorrect filtering of forms and reports
at:
http://allenbrowne.com/bug-02.html
This bug has been fixed in Access 2007, but still applies to Access 95, 97,
2000, 2002, and 2003.

--
Allen Browne - Microsoft MVP. Perth, Western Australia

Reply to group, rather than allenbrowne at mvps dot org.

Ed Crawford said:
I'm trying to apply the following via a command button on a subform. When
I
click the command button when the form is not opened as a subform (F11 and
opening the form directly) all works fine. However, when I open my main
form
(frmTabOpportunity) which contains my subform (frmTask) the command button
on
the subform no longer works.

DoCmd.ApplyFilter , "closed=no"

Any suggestions?
 
Are you sure that the name of the subform control is frmTask? Depending on
how you added the subform to the parent form, the name of the control may be
different than the name of the form being used as a subform. It's the name
of the control you need to use.

--
Doug Steele, Microsoft Access MVP

(no private e-mails, please)


Ed Crawford said:
I get a "method or data member not found" error. I'm assuming the first
line
literally should be

With Me.frmTask.Form

Is that correct?

Allen Browne said:
Assign the string to the Filter property of the subform, and toggle
FilterOn
as well:

With Me.[NameOfYourSubformHere].Form
.Filter = "closed=no"
.FilterOn = True
End With

If you apply a filter to both the main form and the subform, Access can
get
confused. Details in:
Incorrect filtering of forms and reports
at:
http://allenbrowne.com/bug-02.html
This bug has been fixed in Access 2007, but still applies to Access 95,
97,
2000, 2002, and 2003.

--
Allen Browne - Microsoft MVP. Perth, Western Australia

Reply to group, rather than allenbrowne at mvps dot org.

Ed Crawford said:
I'm trying to apply the following via a command button on a subform.
When
I
click the command button when the form is not opened as a subform (F11
and
opening the form directly) all works fine. However, when I open my
main
form
(frmTabOpportunity) which contains my subform (frmTask) the command
button
on
the subform no longer works.

DoCmd.ApplyFilter , "closed=no"

Any suggestions?
 
I see nothing that would indicate the control name (the form)is anything
other than the form name. Does make any difference that the subform is on a
page 7 of a tabbed form (the main form)?

Ed

Douglas J. Steele said:
Are you sure that the name of the subform control is frmTask? Depending on
how you added the subform to the parent form, the name of the control may be
different than the name of the form being used as a subform. It's the name
of the control you need to use.

--
Doug Steele, Microsoft Access MVP

(no private e-mails, please)


Ed Crawford said:
I get a "method or data member not found" error. I'm assuming the first
line
literally should be

With Me.frmTask.Form

Is that correct?

Allen Browne said:
Assign the string to the Filter property of the subform, and toggle
FilterOn
as well:

With Me.[NameOfYourSubformHere].Form
.Filter = "closed=no"
.FilterOn = True
End With

If you apply a filter to both the main form and the subform, Access can
get
confused. Details in:
Incorrect filtering of forms and reports
at:
http://allenbrowne.com/bug-02.html
This bug has been fixed in Access 2007, but still applies to Access 95,
97,
2000, 2002, and 2003.

--
Allen Browne - Microsoft MVP. Perth, Western Australia

Reply to group, rather than allenbrowne at mvps dot org.

I'm trying to apply the following via a command button on a subform.
When
I
click the command button when the form is not opened as a subform (F11
and
opening the form directly) all works fine. However, when I open my
main
form
(frmTabOpportunity) which contains my subform (frmTask) the command
button
on
the subform no longer works.

DoCmd.ApplyFilter , "closed=no"

Any suggestions?
 
The tab page does not come into the name.

Open the main form in design view.
Right-click the edge of the subform control, and choose Properties.
What is the Name property (first item on the Other tab)?

--
Allen Browne - Microsoft MVP. Perth, Western Australia

Reply to group, rather than allenbrowne at mvps dot org.

Ed Crawford said:
I see nothing that would indicate the control name (the form)is anything
other than the form name. Does make any difference that the subform is on
a
page 7 of a tabbed form (the main form)?

Ed

Douglas J. Steele said:
Are you sure that the name of the subform control is frmTask? Depending
on
how you added the subform to the parent form, the name of the control may
be
different than the name of the form being used as a subform. It's the
name
of the control you need to use.

--
Doug Steele, Microsoft Access MVP

(no private e-mails, please)


Ed Crawford said:
I get a "method or data member not found" error. I'm assuming the first
line
literally should be

With Me.frmTask.Form

Is that correct?

:

Assign the string to the Filter property of the subform, and toggle
FilterOn
as well:

With Me.[NameOfYourSubformHere].Form
.Filter = "closed=no"
.FilterOn = True
End With

If you apply a filter to both the main form and the subform, Access
can
get
confused. Details in:
Incorrect filtering of forms and reports
at:
http://allenbrowne.com/bug-02.html
This bug has been fixed in Access 2007, but still applies to Access
95,
97,
2000, 2002, and 2003.

I'm trying to apply the following via a command button on a subform.
When
I
click the command button when the form is not opened as a subform
(F11
and
opening the form directly) all works fine. However, when I open my
main
form
(frmTabOpportunity) which contains my subform (frmTask) the command
button
on
the subform no longer works.

DoCmd.ApplyFilter , "closed=no"
 
frmTask

Allen Browne said:
The tab page does not come into the name.

Open the main form in design view.
Right-click the edge of the subform control, and choose Properties.
What is the Name property (first item on the Other tab)?

--
Allen Browne - Microsoft MVP. Perth, Western Australia

Reply to group, rather than allenbrowne at mvps dot org.

Ed Crawford said:
I see nothing that would indicate the control name (the form)is anything
other than the form name. Does make any difference that the subform is on
a
page 7 of a tabbed form (the main form)?

Ed

Douglas J. Steele said:
Are you sure that the name of the subform control is frmTask? Depending
on
how you added the subform to the parent form, the name of the control may
be
different than the name of the form being used as a subform. It's the
name
of the control you need to use.

--
Doug Steele, Microsoft Access MVP

(no private e-mails, please)


I get a "method or data member not found" error. I'm assuming the first
line
literally should be

With Me.frmTask.Form

Is that correct?

:

Assign the string to the Filter property of the subform, and toggle
FilterOn
as well:

With Me.[NameOfYourSubformHere].Form
.Filter = "closed=no"
.FilterOn = True
End With

If you apply a filter to both the main form and the subform, Access
can
get
confused. Details in:
Incorrect filtering of forms and reports
at:
http://allenbrowne.com/bug-02.html
This bug has been fixed in Access 2007, but still applies to Access
95,
97,
2000, 2002, and 2003.

I'm trying to apply the following via a command button on a subform.
When
I
click the command button when the form is not opened as a subform
(F11
and
opening the form directly) all works fine. However, when I open my
main
form
(frmTabOpportunity) which contains my subform (frmTask) the command
button
on
the subform no longer works.

DoCmd.ApplyFilter , "closed=no"
 
Okay, then you need to get Access to help you debug this.

Open the form for data (not design.)
Press Ctrl+G to open the Immediate Window.

In the Immediate Window, enter:
? TypeName(Forms![NameOfYourMainForm]!frmTask)
Replace the middle bit with the name of your main form.
You should get the response
Subform

Now try:
? TypeName(Forms![NameOfYourMainForm]!frmTask.Form)
You should get the response:
Form_frmTask

Now try:
? Forms![NameOfYourMainForm]!frmTask.Filter

Once you have the names correct, you can continue with putting the code into
the Click event procedure of a command button on the main form.

--
Allen Browne - Microsoft MVP. Perth, Western Australia

Reply to group, rather than allenbrowne at mvps dot org.

Ed Crawford said:
frmTask

Allen Browne said:
The tab page does not come into the name.

Open the main form in design view.
Right-click the edge of the subform control, and choose Properties.
What is the Name property (first item on the Other tab)?

--
Ed Crawford said:
I see nothing that would indicate the control name (the form)is anything
other than the form name. Does make any difference that the subform is
on
a
page 7 of a tabbed form (the main form)?

Ed

:

Are you sure that the name of the subform control is frmTask?
Depending
on
how you added the subform to the parent form, the name of the control
may
be
different than the name of the form being used as a subform. It's the
name
of the control you need to use.

--
Doug Steele, Microsoft Access MVP

(no private e-mails, please)


I get a "method or data member not found" error. I'm assuming the
first
line
literally should be

With Me.frmTask.Form

Is that correct?

:

Assign the string to the Filter property of the subform, and toggle
FilterOn
as well:

With Me.[NameOfYourSubformHere].Form
.Filter = "closed=no"
.FilterOn = True
End With

If you apply a filter to both the main form and the subform, Access
can
get
confused. Details in:
Incorrect filtering of forms and reports
at:
http://allenbrowne.com/bug-02.html
This bug has been fixed in Access 2007, but still applies to Access
95,
97,
2000, 2002, and 2003.

message
I'm trying to apply the following via a command button on a
subform.
When
I
click the command button when the form is not opened as a subform
(F11
and
opening the form directly) all works fine. However, when I open
my
main
form
(frmTabOpportunity) which contains my subform (frmTask) the
command
button
on
the subform no longer works.

DoCmd.ApplyFilter , "closed=no"
 
The first two worked exactly as you indicated. See below. However the 3rd
one got a run time error 438 saying, "Object doesn't support this property or
method"
? TypeName(Forms![frmTabOpportunity]!frmTask)
SubForm
? TypeName(Forms![frmTabOpportunity]!frmTask.Form)
Form_frmTask

Allen Browne said:
Okay, then you need to get Access to help you debug this.

Open the form for data (not design.)
Press Ctrl+G to open the Immediate Window.

In the Immediate Window, enter:
? TypeName(Forms![NameOfYourMainForm]!frmTask)
Replace the middle bit with the name of your main form.
You should get the response
Subform

Now try:
? TypeName(Forms![NameOfYourMainForm]!frmTask.Form)
You should get the response:
Form_frmTask

Now try:
? Forms![NameOfYourMainForm]!frmTask.Filter

Once you have the names correct, you can continue with putting the code into
the Click event procedure of a command button on the main form.

--
Allen Browne - Microsoft MVP. Perth, Western Australia

Reply to group, rather than allenbrowne at mvps dot org.

Ed Crawford said:
frmTask

Allen Browne said:
The tab page does not come into the name.

Open the main form in design view.
Right-click the edge of the subform control, and choose Properties.
What is the Name property (first item on the Other tab)?

--
I see nothing that would indicate the control name (the form)is anything
other than the form name. Does make any difference that the subform is
on
a
page 7 of a tabbed form (the main form)?

Ed

:

Are you sure that the name of the subform control is frmTask?
Depending
on
how you added the subform to the parent form, the name of the control
may
be
different than the name of the form being used as a subform. It's the
name
of the control you need to use.

--
Doug Steele, Microsoft Access MVP

(no private e-mails, please)


I get a "method or data member not found" error. I'm assuming the
first
line
literally should be

With Me.frmTask.Form

Is that correct?

:

Assign the string to the Filter property of the subform, and toggle
FilterOn
as well:

With Me.[NameOfYourSubformHere].Form
.Filter = "closed=no"
.FilterOn = True
End With

If you apply a filter to both the main form and the subform, Access
can
get
confused. Details in:
Incorrect filtering of forms and reports
at:
http://allenbrowne.com/bug-02.html
This bug has been fixed in Access 2007, but still applies to Access
95,
97,
2000, 2002, and 2003.

message
I'm trying to apply the following via a command button on a
subform.
When
I
click the command button when the form is not opened as a subform
(F11
and
opening the form directly) all works fine. However, when I open
my
main
form
(frmTabOpportunity) which contains my subform (frmTask) the
command
button
on
the subform no longer works.

DoCmd.ApplyFilter , "closed=no"
 
Actually, my 3rd example won't work.
It would need to be:
? Forms![NameOfYourMainForm]!frmTask.Form.Filter

In any case, once you have the names working, you can use them in your code.

The basic approach here is to use the Immediate window to get your reference
right, and then put it in your code.

--
Allen Browne - Microsoft MVP. Perth, Western Australia

Reply to group, rather than allenbrowne at mvps dot org.

Ed Crawford said:
The first two worked exactly as you indicated. See below. However the
3rd
one got a run time error 438 saying, "Object doesn't support this property
or
method"
? TypeName(Forms![frmTabOpportunity]!frmTask)
SubForm
? TypeName(Forms![frmTabOpportunity]!frmTask.Form)
Form_frmTask

Allen Browne said:
Okay, then you need to get Access to help you debug this.

Open the form for data (not design.)
Press Ctrl+G to open the Immediate Window.

In the Immediate Window, enter:
? TypeName(Forms![NameOfYourMainForm]!frmTask)
Replace the middle bit with the name of your main form.
You should get the response
Subform

Now try:
? TypeName(Forms![NameOfYourMainForm]!frmTask.Form)
You should get the response:
Form_frmTask

Now try:
? Forms![NameOfYourMainForm]!frmTask.Filter

Once you have the names correct, you can continue with putting the code
into
the Click event procedure of a command button on the main form.

Ed Crawford said:
frmTask

:

The tab page does not come into the name.

Open the main form in design view.
Right-click the edge of the subform control, and choose Properties.
What is the Name property (first item on the Other tab)?

--
I see nothing that would indicate the control name (the form)is
anything
other than the form name. Does make any difference that the subform
is
on
a
page 7 of a tabbed form (the main form)?

Ed

:

Are you sure that the name of the subform control is frmTask?
Depending
on
how you added the subform to the parent form, the name of the
control
may
be
different than the name of the form being used as a subform. It's
the
name
of the control you need to use.

--
Doug Steele, Microsoft Access MVP

(no private e-mails, please)


message
I get a "method or data member not found" error. I'm assuming the
first
line
literally should be

With Me.frmTask.Form

Is that correct?

:

Assign the string to the Filter property of the subform, and
toggle
FilterOn
as well:

With Me.[NameOfYourSubformHere].Form
.Filter = "closed=no"
.FilterOn = True
End With

If you apply a filter to both the main form and the subform,
Access
can
get
confused. Details in:
Incorrect filtering of forms and reports
at:
http://allenbrowne.com/bug-02.html
This bug has been fixed in Access 2007, but still applies to
Access
95,
97,
2000, 2002, and 2003.

message
I'm trying to apply the following via a command button on a
subform.
When
I
click the command button when the form is not opened as a
subform
(F11
and
opening the form directly) all works fine. However, when I
open
my
main
form
(frmTabOpportunity) which contains my subform (frmTask) the
command
button
on
the subform no longer works.

DoCmd.ApplyFilter , "closed=no"
 
Back
Top