Solved relate combobox value, between two linked subforms (1 Viewer)

Manos39

Registered User.
Local time
Today, 06:55
Joined
Feb 14, 2011
Messages
248
Hello, i tried to associate value of a combo box between two subforms which are linked in my form Fr_Events
Problem i guess is that desired combobox which is in second subform has no rowsource related to first combobox

Specifically i need to populate combobox athletesID (in second subform " Frmsub_Times"), depending on first subform's "Frmsub_Races" selected genderID, to show men or women not both).

I have tried onCurrent event of Frmsub_Races to requery Frmsub_Times athletesID plus others unsuccessfully

I have post a sample of my Db if you could help..
 

Attachments

  • db.accdb
    1.3 MB · Views: 112
Last edited:

strive4peace

AWF VIP
Local time
Today, 08:55
Joined
Apr 3, 2020
Messages
1,003
hi @Manos39,

put the linking controls on the main form:
  • RaceID
  • eventID
  • GenderID
I didn't set Visible to be No, but that would be the next step after you test and ensure it is working ok. By doing it this way, there is no code to link them -- Access will do that automatically.

The RecordSource of Frmsub_Times won't have criteria. And then set LinkMasterFields and LinkChildFields for the subform control to be
  • RaceID;eventID;GenderID

I'm not sure I got the right logic ... but hopefully you can see how to do it.
 

Attachments

  • db_edit220624.accdb
    764 KB · Views: 117

Manos39

Registered User.
Local time
Today, 06:55
Joined
Feb 14, 2011
Messages
248
hi @Manos39,

put the linking controls on the main form:
  • RaceID
  • eventID
  • GenderID
I didn't set Visible to be No, but that would be the next step after you test and ensure it is working ok. By doing it this way, there is no code to link them -- Access will do that automatically.

The RecordSource of Frmsub_Times won't have criteria. And then set LinkMasterFields and LinkChildFields for the subform control to be
  • RaceID;eventID;GenderID

I'm not sure I got the right logic ... but hopefully you can see how to do it.
Thank you for the advice i shall try that way and respond hopefully layer on. Ι also have to say that i have managed to accomplish what i needed but the subforms which worked was i datasheet view only which was not practical and nice.
Then i tried my subforms set to continuous and Same Settings were not working!! I kept trying for half week with settings, reading and testing.. The db was not happy at all showing only male or only female athletes. As strange as it is said.. I could post same db with other main form and two subforms in datasheet only for seeing how strange it is..
Thank you and i ll respond later!!
 

strive4peace

AWF VIP
Local time
Today, 08:55
Joined
Apr 3, 2020
Messages
1,003
Thank you for the advice i shall try that way and respond hopefully layer on. Ι also have to say that i have managed to accomplish what i needed but the subforms which worked was i datasheet view only which was not practical and nice.
Then i tried my subforms set to continuous and Same Settings were not working!! I kept trying for half week with settings, reading and testing.. The db was not happy at all showing only male or only female athletes. As strange as it is said.. I could post same db with other main form and two subforms in datasheet only for seeing how strange it is..
Thank you and i ll respond later!!
you're welcome, @Manos39

I did the example quickly since I'm working on something else today -- so maybe the logic you want isn't quite right. There shouldn't be a different whether you use Datasheet or Continuous forms --- but no need for criteria in the RecordSource when you use LinkMasterField and LinkChildFields.

you also had your ControlSources wrong IF the linking controls would be on the subform ... but that's not the best way

in code behind a subform, if you want to reference a value on another subform, it would be:

Code:
me.parent.otherSubformControlname.form.ControlName
 

Manos39

Registered User.
Local time
Today, 06:55
Joined
Feb 14, 2011
Messages
248
Thank you for advice Crystal, tried the db but still athleteid in 2nd subform keeps populating for selection male and female although 1sr and 2nd subforms have now LinkMasterField and LinkChildFields..

Below i attached the db_differences just to witness how Fr_Galas (with 2 subforms in datashhet view) identical to Fr_Events (with same subforms set as continues) is working as it should, while the other is not .. What is wrong?
 

Attachments

  • 2022-06-24 220015.jpg
    2022-06-24 220015.jpg
    104.9 KB · Views: 100
  • db_edit220624.accdb
    904 KB · Views: 105
  • db_Differences.accdb
    1.6 MB · Views: 115
Last edited:

strive4peace

AWF VIP
Local time
Today, 08:55
Joined
Apr 3, 2020
Messages
1,003
Thank you for advice Crystal, tried the db but still athleteid in 2nd subform keeps populating for selection male and female although 1sr and 2nd subforms have now LinkMasterField and LinkChildFields
you're welcome, @Manos39

It would help if you explain your logic better ... what you're trying to do in real world terms

one of your screenshots shows a drop-down list for a combo RowSource -- you didn't mention that and I didn't look at that when making the sample db which mainly illustrates using LinkMasterFields and LinkChildFields to synchronize one subform to another.

Your screenshot shows issues with the RowSource of a combobox. Instead of embedding references to controls in a RowSource, imo, it's better to modify the SQL to have static values, as opposed to using criteria that refeences form controls (I didn't look, but probably your references are wrong, as were thereferences from another subform (but hopefully you'll get it now). What I generally do in cases where a Rowsource is depndent on critera in a control is, of the AfterUpdate of that control, launch a procedure to change the SQL (SQL that shows all records stored in the TAG property and then that is modified to add criteria with specific values -- or remove criteria (set back to what is in Tag) to show all records -- as needed.

Shortcut key to requery combo (or listbox) when you're in the control is F9. I often put this reminder in the StatusBarText property of a control.

I didn't download your attachment because I already know that RowSources aren't changed. Your application needs to be responsive, and you are the best one to manage where that needs to happen ~
 
Last edited:

Manos39

Registered User.
Local time
Today, 06:55
Joined
Feb 14, 2011
Messages
248
Thank you for responses and advice Crystal.
I thought i wrote what problem was specifically -- need to populate combobox athletesID (in second subform " Frmsub_Times"), depending on first subform's "Frmsub_Races" selected genderID, to show men or women not both)--
Anyway i am far from able learn code (age - time) still thank you very much! might have to compromise and workaround my issue!
 

strive4peace

AWF VIP
Local time
Today, 08:55
Joined
Apr 3, 2020
Messages
1,003
Thank you for responses and advice Crystal.
I thought i wrote ...
you're welcome. @Manos39 -- forgive me for looking too fast to notice all your specifics... hopefully the example back has given you understanding -- for if you are responsible for the database, you must comprehend what is done each step of the way. My goal is to teach, not do it for you ~
 

Users who are viewing this thread

Top Bottom