Is this Possible on a subform??? (1 Viewer)

MiscAlma

Registered User.
Local time
Today, 05:04
Joined
Jul 11, 2019
Messages
11
I am wondering if i can set the control source for a sub-form to be dependent on a field within a Table

So example
Part 1 has Field City is City Z so the Sub-form Control Source is Is form.CityZ
part 2 has Field City is City X so the Sub-form Control Source is form.CityX

and the subform that displays is based on the City Field

Is this possible?
 

theDBguy

I’m here to help
Staff member
Local time
Today, 05:04
Joined
Oct 29, 2018
Messages
21,454
Yes, I think that may be possible.
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 20:04
Joined
May 7, 2009
Messages
19,233
you don't need to change Subform each time the City field in the Main form changes.
just add a subform (normal for all Cities).
then link it to the Main Form:

on the subform's Property Sheet->Data

Link Master Fields: [CityField] (the City textbox on main form)
Link Child Fields: [City Field] (the City textbox on the subform)
 

jdraw

Super Moderator
Staff member
Local time
Today, 08:04
Joined
Jan 23, 2006
Messages
15,379
Can you tell us in non-database terms what you are trying to accomplish? There may be options, but to respond we need to know a little more of your requirement. What is the purpose of the subform? How does subform relate to main form??? Form / subform is typically used where tables have a 1:Many relationship.
 

Uncle Gizmo

Nifty Access Guy
Staff member
Local time
Today, 13:04
Joined
Jul 9, 2003
Messages
16,271
What you want to do is possible, but I can't think of any circumstances where I would do it.. The question you are asking points to a very common problem, in that you have created a set of forms which are practically identical, with minor, superficial differences and different data.

The solution is to stick with one form, but change the data displayed in the form. Instead of switching out the form and replacing the form with another form in your subform/subreport control you can directly access the record source of the form. By accessing the forms record source directly and providing it with a different set of data to be displayed. You can also access anything else in the form, the controls, textboxes, comboboxes, hide them, make them visible, whatever you need to do to provide the slight difference you require regarding the particular set of data displayed in the form...

However I've no idea if this is what you have or what you've done, hence as somebody has already asked, what are you trying to do? And can you provide a sample database? Both are important, a good description of the work process you are trying to imitate in MS Access and a sample database, to give us something to hack around and make work in the desired manner...
 

Uncle Gizmo

Nifty Access Guy
Staff member
Local time
Today, 13:04
Joined
Jul 9, 2003
Messages
16,271
There's a video on my blog HERE:- https://www.niftyaccess.com/subform-time-management-matrix-example/ it's not the same scenario as yours, in this scenario you have four subform/subreport controls and you you display the same form in each of the subform/subreport controls (Sub Form Windows) so you have 4 instances of one form being used. I direct you to it because I think the code may give you some insights into the possibilities...
 

Users who are viewing this thread

Top Bottom