left out the mention of the primary key in the second table.
I have increased your Karma to allow you to post your sample. I will have to re-read your question about 5 more times as I can’t grasp what the purpose is or the use of a listbox or combobox doesn’t quite make sense. If the codes are already in a table, why type them in the listbox? Why not just fill the listbox from the table? What is “tally”?
Is the purpose just to update the Tally?
Great that you have a good project. No it’s not simple. First get the list box to work. (Ratslinger taught me how to do this, and you can find his explanations by searching in Ask so as to not repeat that here.) Then write a macro to fire when the list box is updated which increments the tally for the current record. Is that the first part of what you want to do? And the 2nd part is show somewhere a query of what results you have so far. ??
Yes, EasyTrieve, you have the general idea. I get a clean trigger of a macro using a textbox and the event ‘changed’ – clean meaning it is triggered after a whole code is input.
I like the behavior of a combobox with all the codes pre-loaded but the event ‘text changed’ fires on every character input. I tried to have the macro wait until the whole code is entered, but it is getting the input character-by-character instead of string-at-once.
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
Okay, thanks for the response but you’re misunderstanding the task. Please refer to my comment with the attached example database, and I hope you will understand the task.
Another function I added - entry can be upper or lowercase. The code changes it to upper case.
If this answers your question please click on the (upper left area of my answer).
THANK YOU for a working example of (what should be) a Simple Thing.
I had started off with a old code example that triggers an InitForm subroutine on the “when loading” event in a form (that much worked fine) which creates the database connection and is supposed to set a subroutine UpdateTable to be called upon an object event. An added challenge: some of the example references methods which are no longer in LibO 5.
Thanks to you, I have a solid foundation I can refer to and examine in detail.
Finally! Glad it is what you are looking for. I know you can make adjustments for your needs. As far as code goes, it really is a fairly simple task compared to some others I’ve worked on. The task comprehension was harder for me! Had a temporary mental block!
There is a reason for “tally” … i want to count the number of times the code E5C is encountered and entered, for example. I may or may not (by the time all the codes are tallied [that’s another word for ‘counted’]), have at least one observation of code E5E. But if I get code E5D, I need to count it and I’d like to see as I go if I have encountered at least one of every code in code group E5.
Example database is attached.
TallyDatabase.odb
ps: do you not know the song “Day-O (The Banana Boat Song)” ? or the term ‘tallyman’ ? Tallyman - Wikipedia
Your sample is nothing more that the list in your question (already captured that in my sample). Also, there is nothing showing just what your end result should be. Your answer here makes even less sense. “… i want to count the number of times the code E5C is encountered and entered…”. This is a primary key according to you original question. It can only exist once in the table. How can you count that? What is missing in the sample I provided?
Or is it you really want to see IF code E5C is entered for a CodeGroup? Whole different story than what you are stating!
BTW I know what the word “tally” means. It is a matter of what it incorporates as to why it was asked.
None of the various things I’ve tried have achieved the goal, so I didn’t include the attempt to use LibO BASIC or any of the versions of the Forms which didn’t work.
If it helps, think of this as a sort of inventory problem. I thought I have been very clear in my descriptions of the task and that the task is a simple one. I intend to create was is in essence a tally sheet.
Ignoring 90% of what you wrote, here is what I gather from the above. Each “CodeGroup” should have the following associated "Code"s: xxC, xxD, xxE, xxF & xxG (where xx = same value of “CodeGroup”). Now as you are entering data, you want to know if one or more of these is missing?
I am sorry if you find this confusing. I know code E5C, for example, can only exist once in the table. It is unique. I only want to keep a count of how many times I observe a code and type it in to tally it. All valid codes are known in advance, but not all codes will necessarily be observed and counted.
In different attempts, I built both list boxes and combo boxes with all the valid codes to help with data entry of only valid codes.
(just got the comment) Your comment doesn’t really answer anything. What is being accumulated to be placed in the field “Tally”? You never answered my questions.
No, I don’t want to know how many are missing. I want to count how many times each might be entered as input data.
I had no intention of offending you by asking if you knew the word ‘tally’ and I apologize if you took offense. I would hope you pay attention to all the words (not just 10%) I make the effort to write.