SOLVED: Read values from selected rows in a table control

Hi,

I have been hitting a wall for days now with Table Controls selected records. I tried code from this thread I have found this OpenOffice question where the OP seems satisfied with the answers he received, but I am getting errors upon errors.

With Access2Base, I am able to loop through a list, and retrieve values of selected rows quite easily, but could not find this kind of method for table control.

Can anyone show a simple myForm, myTable example to retrieve column values from selected rows in the table whether it is in Lo Basic or Access2Base. Or, maybe quote some documentation offering one that I might have missed.

Thanks.

@dosreis57
This is off topic. Question is regarding a table control NOT a grid control.
Please delete and ask as a NEW question.

Hello,

Have finally gotten to this. Have attached a simple sample which displays a total of the last column for selected records.

The entire key here is getting the View of the table control so as to get the array of the selected records. For more information on the Model-View of controls see → The Model-View Paradigm.

Once you have the array, obtain the array bounds and use in a loop, getting each record and, in this case, totaling the field data.

The macro is not long and have placed comments within.

Sample -------- GridSelection.odb

Please note, rows must be selected for this to work. Selecting fields in a rows is not a selection.

Thank you very much for taking the time.
Your example is simple, straight to the point, and well commented. It is very helpful.
I had used a workaround adding a ‘select’ boolean in some of my tables, but this was inelegant and very limited when working with more complex queries.

@Lyndhurst

As you have been helped, please help others to know the question has been answered by clicking on the :heavy_check_mark: in upper left area of answer which satisfied the question.