I have a form, with a multiselect listbox that is displaying data from a GROUP BY query, which itself pulls data from more than one (related) tables. What I want to be able to do, is for selected listbox entries find the matching records in one of the tables used in the query and run an update to fill some (currently empty) fields within that table from the form.
Example info below, that mimics the structure I have (which is not changing, this is not a design question, but a how do I do this question):
tParent
tChild
FORM fModify (unbound)
LIST: lstModifySelections using:
GROUPED BY QUERY: qModifytChildFields:
The numbers I have in the real database are much greater, of course.
So a user would multi-select the list items they want and then select some fields on the form such as:
cboFieldAddData1 (to update FieldAddData1)
cboFieldAddData2 (to update FieldAddData2)
cboFieldAddData3 (to update FieldAddData3)
So for example, if they selected the first 2 rows and the last but one row, select the cbo values, press button to UPDATE (in this case a total of 5 records) and those 5 rows now has values from the cbos.
I know how to cycle through a selected listbox. I know how to UPDATE records. But what I don’t know is how to do it based on a grouped query in the scenario above.
I’ve created a second query that has the IDChild in (so shows each record ID, and can no longer be a GROUPED QUERY)… thinking that might be something to help me, but not sure my way forward now… or if I’m barking up the wrong tree. I've been going round in circles for this for days just logically working out how to get there and I'm stuck why is this is such a mental block, I don't know.
2nd query: qModifytChildFieldsWithID
Example info below, that mimics the structure I have (which is not changing, this is not a design question, but a how do I do this question):
tParent
Code:
IDParent Year Type [other fields...]
P1 2016 A
P2 2016 A
P3 2016 B
P4 2015 A
P5 2015 B
tChild
Code:
IDChild FIDP Title Version Location
C1 P1 Title1 VersionA 1.01
C2 P1 Title1 VersionA 1.02
C3 P1 Title1 VersionB 1.03
C4 P2 Title2 VersionZ 2.21
C5 P2 Title3 VersionX 3.00
C6 P3 Title1 VersionA 7.99
C7 P4 Title1 VersionA 4.10
C8 P4 Title1 VersionA 6.11
C9 P4 Title2 VersionY 4.15
C10 P5 Title3 VersionX_1 6.20
C11 P2 Title2 VersionY 9.80
C12 P2 Title2 VersionZ 7.03
C13 P2 Title3 VersionX 10.1
C14 P1 Title1 VersionA 8.99
C15 P2 Title4 VersionG 5.55
[...other fields...]
FieldAddData1 (currently empty)
FieldAddData2 (currently empty)
FieldAddData3 (currently empty)
FORM fModify (unbound)
LIST: lstModifySelections using:
GROUPED BY QUERY: qModifytChildFields:
- Year (group) - from tParent
- Type (group) - from tParent
- Title (group) - from tChild (BOUND)
- Version (group) - from tChild
- Location (count) - from tChild
Code:
Year Type Title Version #Locations (count)
2016 A Title 1 Version A 3 <<<
2016 A Title 1 Version B 1 <<<
2016 A Title 2 Version Z 2
2016 A Title 2 Version Y 1
2016 A Title 3 Version X 2
2016 B Title 1 Version A 1 <<<
2016 A Title 4 Version G 1
So a user would multi-select the list items they want and then select some fields on the form such as:
cboFieldAddData1 (to update FieldAddData1)
cboFieldAddData2 (to update FieldAddData2)
cboFieldAddData3 (to update FieldAddData3)
So for example, if they selected the first 2 rows and the last but one row, select the cbo values, press button to UPDATE (in this case a total of 5 records) and those 5 rows now has values from the cbos.
I know how to cycle through a selected listbox. I know how to UPDATE records. But what I don’t know is how to do it based on a grouped query in the scenario above.
I’ve created a second query that has the IDChild in (so shows each record ID, and can no longer be a GROUPED QUERY)… thinking that might be something to help me, but not sure my way forward now… or if I’m barking up the wrong tree. I've been going round in circles for this for days just logically working out how to get there and I'm stuck why is this is such a mental block, I don't know.
2nd query: qModifytChildFieldsWithID
- Year - from tParent
- Type - from tParent
- IDChild - from tChild
- Title - from tChild
- Version - from tChild
- Location - from tChild