After reading the question a number of times, there seems to be no reason for the “Tally” field in the record. If this is a total of the records in the group, it is not record related and does not belong. If this is a sequential numbering within the group, every time an addition, deletion or change is made to the table, the “Tally” field would need to be re-evaluated and updated for all records within the table.
Counts can always be arrived at using SQL and really don’t need to be stored. The attached sample may be what you are looking for. There are two forms. Form “Code Group” - select a group in the listbox then select it using the button. Code records will be displayed in the Table grid & record count in box next to listbox. Don’t even need this since the record count is already present in the grid control.
The second form “GROUPTABLE” is just the two tables connected via relation. Selecting a record in the “Group” table displays records in the “Code” grid below it. Additions, changes or deletions can be done in either grid. Again, don’t see need for counts.
Sample: GroupCode.odb
Edit:
Ok. So after some searching for lost code (text selection) and a quick bite and last minute switch to your supplied table I am satisfied with this next sample.
Sorry about the confusion, but until you brought up the third party entry I was fixated on just the two mentioned tables. If you think that was difficult, you should try this side of the forum. Sometimes it takes a dentist to extract information.
This sample is the same as the previous with an added form (CodeGroup2) and two macros. One macro is to update the Tally and the other is to clear the Tally figures. I added some detail to the form:
- The grid is not selectable
- The entry to the text box is limited to three characters
- Cursor placed right back in text box after an entry
- Message displayed if item is not found
- Maybe some more but I forgot already
Sample: RevisedGroupCode.odb