By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
431,827 Members | 2,155 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 431,827 IT Pros & Developers. It's quick & easy.

Sub Form Filter?

P: n/a
I have a form that has a Tab Control on it. On one of the tab control
pages, there are only 3 pages, is a combo box based on a field called
departments in a table.

When the user selects one of the departments from the combo box I want a
sub-form to open on the tab control page based on the department
selected.

The sub-form is based on a query that pulls all employee data, so if a
user selects admissions, I want the subform to open and only display
records for the admissions depart.

I can get the sub-form to open and display all the records, but I can
not figure out how to make it display only the records I want.

How would I do this?

Thanks in advance for any help!

Michael Charney

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 13 '05 #1
Share this Question
Share on Google+
14 Replies


P: n/a
The department field on the sub form needs to reference the tab control,
then requery the sub-form whenever you click on a tab.

"Nothing" <me@you.com> wrote in message news:41**********@127.0.0.1...
I have a form that has a Tab Control on it. On one of the tab control
pages, there are only 3 pages, is a combo box based on a field called
departments in a table.

When the user selects one of the departments from the combo box I want a
sub-form to open on the tab control page based on the department
selected.

The sub-form is based on a query that pulls all employee data, so if a
user selects admissions, I want the subform to open and only display
records for the admissions depart.

I can get the sub-form to open and display all the records, but I can
not figure out how to make it display only the records I want.

How would I do this?

Thanks in advance for any help!

Michael Charney

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Nov 13 '05 #2

P: n/a
Nothing wrote:
I have a form that has a Tab Control on it. On one of the tab control
pages, there are only 3 pages, is a combo box based on a field called
departments in a table.

When the user selects one of the departments from the combo box I want a
sub-form to open on the tab control page based on the department
selected.

The sub-form is based on a query that pulls all employee data, so if a
user selects admissions, I want the subform to open and only display
records for the admissions depart.

I can get the sub-form to open and display all the records, but I can
not figure out how to make it display only the records I want.

How would I do this?

Thanks in advance for any help!

Michael Charney

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!


You could put the filter in the query of the subform. In the Criteria
line of Department you could enter something like
Forms!MainFormName!ComboDeptName

Then only records that match the dept combo will be displayed.

Nov 13 '05 #3

P: n/a
I have tried to add the filter in both the criteria of the query and on
the form in the filter property. (Not at the same time) but the form
doesnt change with the change in the combo box. It still displays all
the reords.

Am I doing something wrong? (Stupid question!) Is there some sample code
I can exaime somewhere?

Michael Charney

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 13 '05 #4

P: n/a
Nothing wrote:
I have tried to add the filter in both the criteria of the query and on
the form in the filter property. (Not at the same time) but the form
doesnt change with the change in the combo box. It still displays all
the reords.


In the after update event of the combo box, enter:

me.subFormName.Form.Requery

This will do it for you.

Note also, that if you are going to use standard filter menu items from
Access on the sub form, you may run into some of the difficulty I
mention on a post on Friday.
--
Tim http://www.ucs.mun.ca/~tmarshal/
^o<
/#) "Burp-beep, burp-beep, burp-beep?" - Quaker Jake
/^^ "Whatcha doin?" - Ditto "TIM-MAY!!" - Me
Nov 13 '05 #5

P: n/a
I still can not get this dumb thing to work.

I have added the Me.sub-frmEmplyeeData.Form.Requery to teh combo box's
AfterUpdate event and the query re-runs but will not sort on the
department choice in the combo box.

I dont get it. I can manually query for a department name from the query
and it will accept the input and filter fine, but when I try to make the
sub form do the same thing, it just will not work.

Anyone else have any ideas cause I fresh out now. I must be missing
something somewhere but as for what I have no idea.

Michael Charney

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 13 '05 #6

P: n/a
You need to add it to the Link Child Fields and Link Master Fields in the
subform properties.

"Nothing" <me@you.com> wrote in message news:41**********@127.0.0.1...
I have tried to add the filter in both the criteria of the query and on
the form in the filter property. (Not at the same time) but the form
doesnt change with the change in the combo box. It still displays all
the reords.

Am I doing something wrong? (Stupid question!) Is there some sample code
I can exaime somewhere?

Michael Charney

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!

Nov 13 '05 #7

P: n/a
It will not allow me to because there is nothing attached to the main
form so there is no linking possible, at least that is what Access is
telling me.

I added the sub form by draging a query to the tab control and dropping.
Is this the best way to do this?

Michael Charney

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!
Nov 13 '05 #8

P: n/a
Nothing wrote:
It will not allow me to because there is nothing attached to the main
form so there is no linking possible, at least that is what Access is
telling me.


It's just telling you that you can't use the wizard for entering the link
properties. You can still just type them in yourself.

--
I don't check the Email account attached
to this message. Send instead to...
RBrandt at Hunter dot com
Nov 13 '05 #9

P: n/a
"Rick Brandt" <ri*********@hotmail.com> wrote in news:3556omF4if6qaU1
@individual.net:
Nothing wrote:
It will not allow me to because there is nothing attached to the main
form so there is no linking possible, at least that is what Access is
telling me.


It's just telling you that you can't use the wizard for entering the link
properties. You can still just type them in yourself.


Ok I added the following to the Link Child Fields and the Link master
Fields:

Forms!frmEmployeeData.[Combo14]

Now when I go to the form and select the Tab the query is blank to start. I
select a department and it shows me ALL the records. It still is not seeing
the department name that is selected.

I even changed the combo box to look at a specail query that selects the
department name to make sure I am getting the department name.

I am about ready to just re-write the freakin thing another way. The tab
control in Access flat out sucks!

Sorry a little venting there...

Mike
Nov 13 '05 #10

P: n/a
Nothing wrote:
I still can not get this dumb thing to work.

I have added the Me.sub-frmEmplyeeData.Form.Requery to teh combo box's
AfterUpdate event and the query re-runs but will not sort on the
department choice in the combo box.

I dont get it. I can manually query for a department name from the query
and it will accept the input and filter fine, but when I try to make the
sub form do the same thing, it just will not work.

Anyone else have any ideas cause I fresh out now. I must be missing
something somewhere but as for what I have no idea.

Michael Charney

*** Sent via Developersdex http://www.developersdex.com ***
Don't just participate in USENET...get rewarded for it!


In the Combo's AfterUpdate event you could try something like this
Dim strFilter As String
'assumes the dept is named dept and is a string
'value and not a number. You may be using a
'number in a lookup table, not sure what you
'are using. Thus the quotes around the ComboName.
strFilter = "Dept = '" & Me.ComboName & "'"
Forms!MainFormName!SubFormName.Form.Filter = strFilter
Forms!MainFormName!SubFormName.Form.FilterOn = True

As also mentioned regarding the Link Master/Child, single click on the
subform and pull up the property sheet for it. You will see the
properties to link the Master to Child.
Nov 13 '05 #11

P: n/a
Michael Charney wrote:
"Rick Brandt" <ri*********@hotmail.com> wrote in news:3556omF4if6qaU1
@individual.net:
Nothing wrote:
It will not allow me to because there is nothing attached to the
main form so there is no linking possible, at least that is what
Access is telling me.
It's just telling you that you can't use the wizard for entering the
link properties. You can still just type them in yourself.


Ok I added the following to the Link Child Fields and the Link master
Fields:

Forms!frmEmployeeData.[Combo14]


All you need is "Combo14" (without the quotes) in the MasterLink property
and the name of the corresponding field in the subform. For ChildLink it
has to be a field name and not just a control name.
Now when I go to the form and select the Tab the query is blank to
start. I select a department and it shows me ALL the records. It
still is not seeing the department name that is selected.

I even changed the combo box to look at a specail query that selects
the department name to make sure I am getting the department name.

I am about ready to just re-write the freakin thing another way. The
tab control in Access flat out sucks!


None of this has anything to do with the TabControl. What you are "meesing
with" are properties and behaviors of a subform. If there were no
TabControl involved it would be exactly the same.

--
I don't check the Email account attached
to this message. Send instead to...
RBrandt at Hunter dot com
Nov 13 '05 #12

P: n/a
"Rick Brandt" <ri*********@hotmail.com> wrote in
news:35*************@individual.net:
Michael Charney wrote:
"Rick Brandt" <ri*********@hotmail.com> wrote in news:3556omF4if6qaU1
@individual.net:
Nothing wrote:
It will not allow me to because there is nothing attached to the
main form so there is no linking possible, at least that is what
Access is telling me.

It's just telling you that you can't use the wizard for entering the
link properties. You can still just type them in yourself.


Ok I added the following to the Link Child Fields and the Link master
Fields:

Forms!frmEmployeeData.[Combo14]


All you need is "Combo14" (without the quotes) in the MasterLink
property and the name of the corresponding field in the subform. For
ChildLink it has to be a field name and not just a control name.
Now when I go to the form and select the Tab the query is blank to
start. I select a department and it shows me ALL the records. It
still is not seeing the department name that is selected.

I even changed the combo box to look at a specail query that selects
the department name to make sure I am getting the department name.

I am about ready to just re-write the freakin thing another way. The
tab control in Access flat out sucks!


None of this has anything to do with the TabControl. What you are
"meesing with" are properties and behaviors of a subform. If there
were no TabControl involved it would be exactly the same.


In the Link master Field I put "Combo14" without the quotes.
In the Link Child Fields I put "[dept]" without the quotes. I also tried
jusst dept.

When I start the form and select the Departments tab, the sub form comes
up blank to start with. I then choose a department but it still shows no
records. Is there anything else you can think of?
Nov 13 '05 #13

P: n/a
Michael Charney wrote:
In the Link master Field I put "Combo14" without the quotes.
In the Link Child Fields I put "[dept]" without the quotes. I also
tried jusst dept.

When I start the form and select the Departments tab, the sub form
comes up blank to start with. I then choose a department but it still
shows no records. Is there anything else you can think of?


Are you sure your ComboBox is not a multi-column one where it can show one
column, but actually be retaining the value of a different one?

--
I don't check the Email account attached
to this message. Send instead to...
RBrandt at Hunter dot com
Nov 13 '05 #14

P: n/a
Try placing a hidden field on the form then update it to the department
whenever you change tabs. Reference this field with the subform. Set the
default value to whatever is the default tab.

"Michael Charney" <no*****@me.com> wrote in message
news:Fm*****************@newssvr31.news.prodigy.co m...
"Rick Brandt" <ri*********@hotmail.com> wrote in
news:35*************@individual.net:
Michael Charney wrote:
"Rick Brandt" <ri*********@hotmail.com> wrote in news:3556omF4if6qaU1
@individual.net:

Nothing wrote:
> It will not allow me to because there is nothing attached to the
> main form so there is no linking possible, at least that is what
> Access is telling me.

It's just telling you that you can't use the wizard for entering the
link properties. You can still just type them in yourself.
Ok I added the following to the Link Child Fields and the Link master
Fields:

Forms!frmEmployeeData.[Combo14]


All you need is "Combo14" (without the quotes) in the MasterLink
property and the name of the corresponding field in the subform. For
ChildLink it has to be a field name and not just a control name.
Now when I go to the form and select the Tab the query is blank to
start. I select a department and it shows me ALL the records. It
still is not seeing the department name that is selected.

I even changed the combo box to look at a specail query that selects
the department name to make sure I am getting the department name.

I am about ready to just re-write the freakin thing another way. The
tab control in Access flat out sucks!


None of this has anything to do with the TabControl. What you are
"meesing with" are properties and behaviors of a subform. If there
were no TabControl involved it would be exactly the same.


In the Link master Field I put "Combo14" without the quotes.
In the Link Child Fields I put "[dept]" without the quotes. I also tried
jusst dept.

When I start the form and select the Departments tab, the sub form comes
up blank to start with. I then choose a department but it still shows no
records. Is there anything else you can think of?

Nov 13 '05 #15

This discussion thread is closed

Replies have been disabled for this discussion.