Main form, Tab control, subforms and a query question

  • Thread starter Thread starter Corey-g via AccessMonster.com
  • Start date Start date
C

Corey-g via AccessMonster.com

Hi All,

I am trying to build a main form, that will have a tab control and 2 pages
each with a subform (the easy part) . I have this already, but I have 2
seperate forms and 2 query's for the tab control pages. I figured this is
not the best way - if I had to make a change, I have to do it twice - I'd
rather figure out how to build it to reuse them. And then I may be able to
apply that to other forms still to come.

What I would like to do is:

Have one query, and one form as the subform for both tab pages, and have it
filter based on which page it's one.

So the structure I'm working with is like so:

Items table - item_id (pk), part number, qty, channel_id

Channel type table - channel_id (pk), channel name (only 2 values 'A' & 'B')

So currently the 2 forms I have are identical except the recordsource, and
the 2 queries I have are identical except the criteria value for channel_id
('A' for one, 'B' for the other) but both select * from items where...

Anyone able to point me in the right direction?

thanks,

Corey
 
Corey-g via AccessMonster.com said:
I am trying to build a main form, that will have a tab control and 2 pages
each with a subform (the easy part) . I have this already, but I have 2
seperate forms and 2 query's for the tab control pages. I figured this is
not the best way - if I had to make a change, I have to do it twice - I'd
rather figure out how to build it to reuse them. And then I may be able to
apply that to other forms still to come.

What I would like to do is:

Have one query, and one form as the subform for both tab pages, and have it
filter based on which page it's one.

So the structure I'm working with is like so:

Items table - item_id (pk), part number, qty, channel_id

Channel type table - channel_id (pk), channel name (only 2 values 'A' & 'B')

So currently the 2 forms I have are identical except the recordsource, and
the 2 queries I have are identical except the criteria value for channel_id
('A' for one, 'B' for the other) but both select * from items where...


Try Adding two hidden text boxes to the main form. Name them
txtA and txtB and set their control source to ="A" and ="B"

Then set subformA's LinkMaster property to txtA and
similarly for subformB

Then remove the cirteria from the query.
 
Thanks Marshall.

I am trying to implement this as you suggested, but when I attempt to add the
"Link Child Fields" or "Link Master Fields" I get a pop up saying:

"Can't build a link between unbound forms."

I don't have the main form bound... I guess I could bind the main form to
the channel table, but will this cause any underling changes to this table
when records change? The purpose of this form is to group and display
similar items (from the same channel) so that the user can "change" the
channel if required. And I would like the 'changed item' to show up on the
other tab immediately if this happens. I have bound the 'subform' to a query
that does the grouping and such, and set the 'channel_id' field to a combobox
- with it's control source as Channel_ID, and recordsource to the Channel
table...

I tried to add in the recordsource for the main form - to the table "Channel",
but when I opened the form - no data was displayed...

And I know I can't 'update' the data because of the aggregate function
(grouping), so is there a way I can do this? Or should I go back to the 2
forms and 2 query's method?

Thanks again Marshall !!!

Corey
 
Sorry, and I should add that I 'was' going to use code to make the change in
channel for the item(s) - as the query that the subform is based on is non-
updatable...
 
Corey-g via AccessMonster.com said:
Sorry, and I should add that I 'was' going to use code to make the change in
channel for the item(s) - as the query that the subform is based on is non-
updatable...


There's no problem with the main form being unbound so don't
mess with that. Only the subform need to be bound.

You can use a single hidden text box and use the tab
control's Change event to set the text box's value to A or
B, but I don't see any benefit.

Did you set the subform controls' LinkChildFields property
to the channel name field (which must be in the subform's
record source)?
 
Marshall, You are the man!!!

I totally missed the '=' in the control source for the textbox - so I just
had it as '1'... Sorry, after re-reading the post I tried "=1", and
everything looks to work correctly...

Much Appreicated...

Corey
 
Back
Top