1 (edited by AD1408 2017-02-21 11:25:06)

Topic: Table records with multi sub records

I couldn't get my head around on this.


Due to too may fields (in actual project) I've created different db tables and linked to main table. However, I cannot get sub records details displayed.


Please see the sample project below. I have added additional info about the issue on forms:

Post's attachments

Attachment icon Table records with multi sub records.zip 14.92 kb, 451 downloads since 2017-02-21 

Adam
God... please help me become the person my dog thinks I am.

Re: Table records with multi sub records

Hi Adam,
Just had a quick look but haven't had time to test it properly (in a rush!!).
Is this what you are hoping to do? (I've done it for students but not for courses).
As always with MVD, other ways of doing it, but this might be one approach.
Regards,
Derek.

Post's attachments

Attachment icon Table records with multi sub records fixed.zip 348.91 kb, 481 downloads since 2017-02-21 

Re: Table records with multi sub records

Hi Derek,


Thanks a lot...............


I got the students part later on using button4, same way as you did with button5, thanks to your fix for another member.


However, I cannot get course details displayed for selected school.

Adam
God... please help me become the person my dog thinks I am.

Re: Table records with multi sub records

Hi,
It's the same principle - the only difference is that the incremental search is already being used to retrieve student details (so you need to add another button to search for the courses and action the 'click' in the script instead).
You were also retrieving the course details when the value in the schools grid was changing rather than when the value in the courses grid was changing.
One more thing - you really need to repeat all your sql calls AFTER you've done an 'edit' as well, because the updated details will not show (try editing some data on either a student record or a course record and you'll see that your changes are not showing - it's different from just issuing a 'dbupdate' command).  It's probably quite inefficient and will make the script rather long-winded (well, you know how I love a minimal script - LOL!).
Anyway, I think it's doing what you want now.
Derek.

Post's attachments

Attachment icon Table records with multi sub records fixed2.zip 351.01 kb, 447 downloads since 2017-02-21 

5 (edited by AD1408 2017-02-21 21:29:48)

Re: Table records with multi sub records

Thanks a lot Derek...........


Perhaps courses was a bad subject to pick. It could be school garden details. What I want with courses is to display course details  belonging to a selected school without courses tGrid. Imagine each school having only one course.

Adam
God... please help me become the person my dog thinks I am.

6 (edited by AD1408 2017-02-22 18:37:21)

Re: Table records with multi sub records

I have updated the test project. Please see the attached...


1. I have changed courses table to library so that it makes better sense in respect of what I'm trying to do. Issue of displaying library details of selected school on form1 / School Library tab?


2. Another issue I have noticed. When double click on a record on SCHOOLS tGrid it opens two form; frmSchool and frmLibrary. When clicked on edit button it opens the correct form only. How can we make it to open active tab specific form on doubleclick too? This item is SOLVED thanks to Dmitry's script. However other items are still not resolved.


3. I have tried to use different method (thanks to bemorhona-qt) to refresh records display after add/edit/delete. However, my implementation works partially. On schools tGrid/details only delete refreshes.  On Students tGrid Edit and Delete refreshes but not Add. Perhaps bemorhona-qt could offer a help again?


4. I couldn't find the way to work DateTime component spinbox arrows?

Post's attachments

Attachment icon Table records with multi sub records2.zip 16.81 kb, 450 downloads since 2017-02-22 

Adam
God... please help me become the person my dog thinks I am.

Re: Table records with multi sub records

Hi Dmitry,


Looks like your help needed here please, especially for the issue number 1 on my previous post  #6

Adam
God... please help me become the person my dog thinks I am.

Re: Table records with multi sub records

AD1408 wrote:

Hi Dmitry,


Looks like your help needed here please, especially for the issue number 1 on my previous post  #6

Hello.


Please check out fixed project.


Now you can see library of selected school, also you can edit library.
But if one school can have only one library, you should use one table for school and library. Because if you create two library for one school, which library you should show in tab "School Library"?

Post's attachments

Attachment icon Table records with multi sub records2_fixed.zip 17.82 kb, 509 downloads since 2017-02-23 

Dmitry.

Re: Table records with multi sub records

Thank you very much Dmitry...................................................
It does the job as I wanted.


But if one school can have only one library, you should use one table for school and library. Because if you create two library for one school, which library you should show in tab "School Library"?

School has too many fields (well over 500) to manage in one table, hence I wanted to breakdown into different tables. If school has multiple entities like in students, then I use secondary table. In this example library is just one of many school details. Anyhow, thanks for the heads up.

Adam
God... please help me become the person my dog thinks I am.

Re: Table records with multi sub records

Hi Adam,
Meant to follow up on your question but have been tied up.
Rather than have lots of SQL statements to retrieve fields that you want to display, you can do most of it as part of standard MVD. 
Basically, in your script, you automate 'clicking' an edit button so as you scroll through your grid, it retrieves as many fields of data as you want without any additional SQL calls.  And because it is pretty much standard MVD, there should be no issues with refreshing and updating.
Have a look at the attached project and it might give you a different approach.
It's something I did a while back but I've changed some of it to be relevant to your question.  I use panels instead of page controls / tab sheets but the principle is identical and there is a mix of data coming from both the main and the related tables.
Although there are a few lines of code in the script, 95% of it is either cosmetic or to safeguard against the user creating duplicate rows (because it's all on one form).
Hope it helps,
Derek.

Post's attachments

Attachment icon adamschoolsoneform.zip 352.61 kb, 482 downloads since 2017-02-24 

11 (edited by AD1408 2017-02-24 15:27:44)

Re: Table records with multi sub records

Hi Derek,


Thank you very much for the example. It doesn't suit the project in hand I'm playing with due to way too many fields for schools table. It's difficult to manage over 500 fields on a single table. However, your kind example is appreciated as I learn a lot from your posts (remembering all with my one cell brain is another matter tho.. lol)


Derek, is your example one form doable without additional two forms you have used?


EDIT:  I think I managed to work out my issue described below by using onShow button.click.
--------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------


Now I stuck with another issue. I thought this would be easy but couldn't do it. Basically, I'm trying to copy ItemX and ItemY field values from one form to another and display them on form1 relevant section. Please see the image below for better explanation as to what I'm trying to do.
https://s8.postimg.org/xezmscuth/zzzzz_Temp1.png


Updated sample project attached:

Post's attachments

Attachment icon Table records with multi sub records3.zip 19.16 kb, 461 downloads since 2017-02-24 

Adam
God... please help me become the person my dog thinks I am.

Re: Table records with multi sub records

Hello.


Check it.

Post's attachments

Attachment icon Table records with multi sub records3_fixed.zip 18.88 kb, 505 downloads since 2017-02-27 

Dmitry.