Filter subform for current record on main form

  • Thread starter HELLO via AccessMonster.com
  • Start date
H

HELLO via AccessMonster.com

How can one filter a subform just for the current record on the main form?
That is, when you move to another record on the main form the filter is
"undone"? Thank you.
 
D

Douglas J Steele

Put code in the main form's Current event to reset the filter.

Me!SubformControl.Form.FilterOn = False
Me!SubformControl.Form.Filter = vbNullString

Note that SubformControl may or may not be the same name as the form being
used as a subform. If you created the subform by dragging one form on top of
another, they should be the same. If you created the subform by dragging a
subform control from the tool box onto the parent form then providing the
necessary information (either manually or using the wizard), the subform
control will likely be named something like Child1 (where the number will
vary)
 
H

HELLO via AccessMonster.com

Thank you for your reply Douglas. I've tried and it didn't work. But I think
I forgot to say that I filter the subform with a combo that provides criteria
to a query. Does this make any difference?
 
D

Douglas J Steele

What exactly do you mean by "it didn't work"?

Do you get an error? If so, what error are you getting? Does the filter not
got away? If so, are you sure that the code is actually running (put a break
point in to make sure)?

If the underlying recordset for the subform is supposed to be changing, is
that happening correctly?
 
H

HELLO via AccessMonster.com

Hi Douglas, thank you again, i hope you're still there. Well, nothing happens
(and I don't get any error message). But what exactly do you mean by subform
control, is it the subform name?

Thank you.

HELLO
What exactly do you mean by "it didn't work"?

Do you get an error? If so, what error are you getting? Does the filter not
got away? If so, are you sure that the code is actually running (put a break
point in to make sure)?

If the underlying recordset for the subform is supposed to be changing, is
that happening correctly?
Thank you for your reply Douglas. I've tried and it didn't work. But I think
I forgot to say that I filter the subform with a combo that provides criteria
[quoted text clipped - 16 lines]
 
D

Douglas J Steele

I thought I did a pretty thorough job of expliaing what the subform control
is in my previous post...

On your main form, you'll have a subform control that's linked to whatever
form it is you're using as a subform. The name of the subform control may or
may not be the same as the name of the form being used as a subform.

If you created the form/subform relationship by dragging one form onto the
other, then the subform control will most likely be named the same as the
form being used as the subform. However, if you added a subform control to
the form then filled in the necessary information, the subform control will
likely be named something like Child0 (where the digit will vary)

What's the actual code you're using?

--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)


HELLO via AccessMonster.com said:
Hi Douglas, thank you again, i hope you're still there. Well, nothing happens
(and I don't get any error message). But what exactly do you mean by subform
control, is it the subform name?

Thank you.

HELLO
What exactly do you mean by "it didn't work"?

Do you get an error? If so, what error are you getting? Does the filter not
got away? If so, are you sure that the code is actually running (put a break
point in to make sure)?

If the underlying recordset for the subform is supposed to be changing, is
that happening correctly?
Thank you for your reply Douglas. I've tried and it didn't work. But I think
I forgot to say that I filter the subform with a combo that provides
criteria
[quoted text clipped - 16 lines]
That is, when you move to another record on the main form the filter is
"undone"? Thank you.
 
H

HELLO via AccessMonster.com

Thanks for your reply Douglas. I'm glad you're still there.

I' ve entered the following on the "On Current" event of the main form:

Me!Mysubformname.Form.FilterOn = False
Me!Mysubformname.Form.Filter = vbNullString

But as you say, this doesn't work in my case because I've added the subform
control to the subform. The problem is, you mention in your posts that the
subform control may or may not be the same as the
subform name (which I didn't know) and so I don't know where to check the
"subform control" name that you are referring to (since it's not the subform
name). Where can I check this name? This is my problem...
I thought I did a pretty thorough job of expliaing what the subform control
is in my previous post...

On your main form, you'll have a subform control that's linked to whatever
form it is you're using as a subform. The name of the subform control may or
may not be the same as the name of the form being used as a subform.

If you created the form/subform relationship by dragging one form onto the
other, then the subform control will most likely be named the same as the
form being used as the subform. However, if you added a subform control to
the form then filled in the necessary information, the subform control will
likely be named something like Child0 (where the digit will vary)

What's the actual code you're using?
Hi Douglas, thank you again, i hope you're still there. Well, nothing happens
(and I don't get any error message). But what exactly do you mean by subform
[quoted text clipped - 18 lines]
 
M

Miguel Alexandre via AccessMonster.com

Sorry, of course "i've added the subform control to the main form"...
Corrected.
Thanks for your reply Douglas. I'm glad you're still there.

I' ve entered the following on the "On Current" event of the main form:

Me!Mysubformname.Form.FilterOn = False
Me!Mysubformname.Form.Filter = vbNullString

But as you say, this doesn't work in my case because I've added the subform
control to the subform. The problem is, you mention in your posts that the
subform control may or may not be the same as the
subform name (which I didn't know) and so I don't know where to check the
"subform control" name that you are referring to (since it's not the subform
name). Where can I check this name? This is my problem...
I thought I did a pretty thorough job of expliaing what the subform control
is in my previous post...
[quoted text clipped - 16 lines]
 
H

HELLO/Miguel Alexandre via AccessMonster.com

PS.: I'm still the same.

Miguel said:
Sorry, of course "i've added the subform control to the main form"...
Corrected.
Thanks for your reply Douglas. I'm glad you're still there.
[quoted text clipped - 15 lines]
 
D

Douglas J. Steele

It's a control on the form. You check its name the same way you check any
other control name,

--
Doug Steele, Microsoft Access MVP

(no private e-mails, please)


HELLO via AccessMonster.com said:
Thanks for your reply Douglas. I'm glad you're still there.

I' ve entered the following on the "On Current" event of the main form:

Me!Mysubformname.Form.FilterOn = False
Me!Mysubformname.Form.Filter = vbNullString

But as you say, this doesn't work in my case because I've added the
subform
control to the subform. The problem is, you mention in your posts that the
subform control may or may not be the same as the
subform name (which I didn't know) and so I don't know where to check the
"subform control" name that you are referring to (since it's not the
subform
name). Where can I check this name? This is my problem...
I thought I did a pretty thorough job of expliaing what the subform
control
is in my previous post...

On your main form, you'll have a subform control that's linked to whatever
form it is you're using as a subform. The name of the subform control may
or
may not be the same as the name of the form being used as a subform.

If you created the form/subform relationship by dragging one form onto the
other, then the subform control will most likely be named the same as the
form being used as the subform. However, if you added a subform control to
the form then filled in the necessary information, the subform control
will
likely be named something like Child0 (where the digit will vary)

What's the actual code you're using?
Hi Douglas, thank you again, i hope you're still there. Well, nothing
happens
(and I don't get any error message). But what exactly do you mean by
subform
[quoted text clipped - 18 lines]
That is, when you move to another record on the main form the
filter is
"undone"? Thank you.
 
M

Miguel Alexandre via AccessMonster.com

Finally solved the issue. On the subform current event i've just typed

mysearchcombo=null

and that's it. When I move to another record, either in the main form or on
the subform, the combo box is cleared and so is the criteria for the query
(my "filter")...

Thanks for your help!
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top