Solved Syncronizing two related subforms (1 Viewer)

SuperSonicSam

New member
Local time
Today, 19:17
Joined
Jul 16, 2023
Messages
23
Hi there, can anyone help me troubleshoot the following problem? I am trying to link two subforms (housed in an unbound parent form) so that when I click on the continuous subform on the LHS, the records displayed in the the RHS subform match. Please see the first attachment. So far I haven't had success, even after searching on the web and using a 'txtMasterID' workaround. Also not sure if it's relevant (I am a beginner), but the tabs in the form on the RHS aren't connected to the rest of the form in the conventional way (see second attachement). More than happy to have any advise.
 

Attachments

  • AccessFormSideBySide1.pdf
    116.1 KB · Views: 88
  • AccessStudentDetailsMainForm.pdf
    129.1 KB · Views: 75

Josef P.

Well-known member
Local time
Today, 11:17
Joined
Feb 2, 2023
Messages
826
There are several options. 3 variants that I usually use:
  • You can react in the main form to the current events of the subforms and then set the other one to the same record
  • You can use the same recordset in both forms
  • If you only navigate on the left side, you can bind the right subform to the primary key data field of the left side (easiest to do with a text field in the main form).

BTW: You can also insert images directly into the post, then you don't have to open a PDF file.
 

isladogs

MVP / VIP
Local time
Today, 10:17
Joined
Jan 14, 2017
Messages
18,224
See my article which has several solutions to doing this:

 

mike60smart

Registered User.
Local time
Today, 10:17
Joined
Aug 6, 2017
Messages
1,905
Hi there, can anyone help me troubleshoot the following problem? I am trying to link two subforms (housed in an unbound parent form) so that when I click on the continuous subform on the LHS, the records displayed in the the RHS subform match. Please see the first attachment. So far I haven't had success, even after searching on the web and using a 'txtMasterID' workaround. Also not sure if it's relevant (I am a beginner), but the tabs in the form on the RHS aren't connected to the rest of the form in the conventional way (see second attachement). More than happy to have any advise.
Hi
Are you able to upload your actual database or a copy containing no confidential data?
 

mike60smart

Registered User.
Local time
Today, 10:17
Joined
Aug 6, 2017
Messages
1,905
Hi
Are you able to upload your actual database or a copy containing no confidential data?
Hi
Your relationships between tables is all wrong

You should be linking PrimaryKey to ForeignKey in related tables.

You have set up links as follows which show as Indeterminate when they should be One to Many.

The normal setup for your scenario is a Main Form based on StudentDetails with a
Subform containing a Tab Control with Pages for all related tables??

Why are you trying to link a Subform based on StudentDetails to another Subform based on the same StudentDetails??
 

Attachments

  • Indeterminate.jpg
    Indeterminate.jpg
    40.9 KB · Views: 46

SuperSonicSam

New member
Local time
Today, 19:17
Joined
Jul 16, 2023
Messages
23
Hi mike60smart, thanks very much for your response. Please find database attached.
 

Attachments

  • SAssess22Jul23.accdb
    1.7 MB · Views: 67

SuperSonicSam

New member
Local time
Today, 19:17
Joined
Jul 16, 2023
Messages
23
FYI student with ID '2' has the most complete data shown throughout the subform tabs
 

SuperSonicSam

New member
Local time
Today, 19:17
Joined
Jul 16, 2023
Messages
23
Thanks mike60smart! You've solved the synchronisation problem, however, the tabbed part of the second subform section no longer functions.... I'm now convinced this has something to do with the unconventional way it was set up (i.e. with simple code in the 'on change event') in an effort to gain faster load times. Is it possible to get this tabbed part of subform working again using it's current configuration or does it need to be re-done using the conventional configuration?
 

mike60smart

Registered User.
Local time
Today, 10:17
Joined
Aug 6, 2017
Messages
1,905
Thanks mike60smart! You've solved the synchronisation problem, however, the tabbed part of the second subform section no longer functions.... I'm now convinced this has something to do with the unconventional way it was set up (i.e. with simple code in the 'on change event') in an effort to gain faster load times. Is it possible to get this tabbed part of subform working again using it's current configuration or does it need to be re-done using the conventional configuration?
Hi
Is this version better?
 

Attachments

  • SAssess22Jul23 v2.zip
    223.3 KB · Views: 64

SuperSonicSam

New member
Local time
Today, 19:17
Joined
Jul 16, 2023
Messages
23
Hi, the tabbed control in the second subform still no longer working (i.e. when clicking on the tabs, the subforms aren't displayed in the unbound SubformContainer which is immediately below the tab control.....see this area working correctly in the initial version posted of this database, before you corrected the synchronisation problem...thanks again for doing that). It may be the case that I just have to scrap the simple code in the 'on change' event (used to achieve faster load times) and re-do the tabbed subform using the usual method. Do you think that's the case?
 

isladogs

MVP / VIP
Local time
Today, 10:17
Joined
Jan 14, 2017
Messages
18,224
Did you look at the examples in post #3 link?
 

mike60smart

Registered User.
Local time
Today, 10:17
Joined
Aug 6, 2017
Messages
1,905
Hi, the tabbed control in the second subform still no longer working (i.e. when clicking on the tabs, the subforms aren't displayed in the unbound SubformContainer which is immediately below the tab control.....see this area working correctly in the initial version posted of this database, before you corrected the synchronisation problem...thanks again for doing that). It may be the case that I just have to scrap the simple code in the 'on change' event (used to achieve faster load times) and re-do the tabbed subform using the usual method. Do you think that's the case?
Hi

You cannot just click a Tab Control and expect data to be displayed.

The process is you 1st select a Student in the Left Subform
Then all related data is displayed in the Tab Control Page you then select.
I attach the file again.
 

Attachments

  • SyncSubforms22Jul23 v2.zip
    226.9 KB · Views: 62

Gasman

Enthusiastic Amateur
Local time
Today, 10:17
Joined
Sep 21, 2011
Messages
14,301
You cannot just click a Tab Control and expect data to be displayed.
Mike,
The OP is setting the object source on each tab as it is selected, as opposed to loading all subforms on the load of the form.
 

Gasman

Enthusiastic Amateur
Local time
Today, 10:17
Joined
Sep 21, 2011
Messages
14,301
@SuperSonicSam
If there is no data for a subform, it appears blank. So your subform appears not to work, but it actually does, it is the data that is at fault, (or your logic)?
DO NOT call a field ID without any other text. How is Access meant to know which is which. :(
In the spelling table you should have the FK as StudentIDFK or something along those lines to indicate

1. It is the StudentID
2. That is a Foreign Key to another table.
 

mike60smart

Registered User.
Local time
Today, 10:17
Joined
Aug 6, 2017
Messages
1,905
Mike,
The OP is setting the object source on each tab as it is selected, as opposed to loading all subforms on the load of the form.
Hi WGM

Yes and this is what happens in the example I uploaded.
There are no Subforms in the Second Subform just a TabControl with a number of Pages named "tabctlEval"
with an Unbound Control named "SubformContainer"

As long as the OP selects a specific Student in the 1st Subform then related data will display in the specific
Tab Control Page selected.

See Screenshot
 

Attachments

  • Screenshot.jpg
    Screenshot.jpg
    100.9 KB · Views: 44

SuperSonicSam

New member
Local time
Today, 19:17
Joined
Jul 16, 2023
Messages
23
Hi Mike & Gasman, FYI this is the video I followed to set up the tab control ( in case I'm not explaining it properly. When you click on each tabbed control I would like each respective subform to be displayed, even when there is no data in it. Would it be better to set up tab control the conventional way.....cause I'm thinking it'll solve problem (albeit result in longer load times).
 

SuperSonicSam

New member
Local time
Today, 19:17
Joined
Jul 16, 2023
Messages
23
@SuperSonicSam
If there is no data for a subform, it appears blank. So your subform appears not to work, but it actually does, it is the data that is at fault, (or your logic)?
DO NOT call a field ID without any other text. How is Access meant to know which is which. :(
In the spelling table you should have the FK as StudentIDFK or something along those lines to indicate

1. It is the StudentID
2. That is a Foreign Key to another table.
Thanks for this info Gasman
 

Users who are viewing this thread

Top Bottom