[AccessD] how to count selected combos in a form

John Colby jwcolby at gmail.com
Fri Nov 3 18:20:50 CDT 2017


And I would probably use a class, one instance for each combo.  Variables and code in the class, a pointer to the combo in the class.

That way if the number of combos varies you just instantiate more or 
less instances.

Sink the combo AfterUpdate right in the class.



On 11/2/2017 9:59 AM, Paul Hartland via AccessD wrote:

There will probably be a better answer than this as not used Access


>   in some
> time, but straight off the top of my head I would use a module with 5
> public variables, something like int_Group_1, int_Group_2 etc, then create
> a function to do the counts of the combo boxes that belong to the specific
> group, then call this function on the Load/Activate of the form and in the
> After Update of each combo box, something like below:
>
> Public int_Group_1 As Integer
> Public int_Group_2 As Integer
> Public int_Group_3 As Integer
> Public int_Group_4 As Integer
> Public int_Group_5 As Integer
>
>
> Public Function fn_Count_Groups()
>      int_Group_1 = iif(IsNull(SRS5), 0, 1) +  iif(IsNull(SRS9), 0, 1)
> +  iif(IsNull(SRS12), 0, 1) +  iif(IsNull(SRS15), 0, 1) +
> iif(IsNull(SRS18), 0, 1)
>      int_Group_2 = iif(IsNull(SRS1), 0, 1) +  iif(IsNull(SRS2), 0, 1)
> +  iif(IsNull(SRS8), 0, 1) +  iif(IsNull(SRS11), 0, 1) +
> iif(IsNull(SRS17), 0, 1)
>      int_Group_3 = iif(IsNull(SRS4), 0, 1) +  iif(IsNull(SRS6), 0, 1)
> +  iif(IsNull(SRS10), 0, 1) +  iif(IsNull(SRS14), 0, 1) +
> iif(IsNull(SRS19), 0, 1)
>      int_Group_4 = iif(IsNull(SRS3), 0, 1) +  iif(IsNull(SRS7), 0, 1)
> +  iif(IsNull(SRS13), 0, 1) +  iif(IsNull(SRS16), 0, 1) +
> iif(IsNull(SRS20), 0, 1)
>      int_Group_5 = iif(IsNull(SRS21), 0, 1) +  iif(IsNull(SRS22), 0, 1)
> End Function
>
> This is just off top of head, so apologies for any spellings etc.
>
> Paul
>
> On 2 November 2017 at 13:39, Kostas Konstantinidis <kost36 at otenet.gr> wrote:
>
>> Dear people,
>>
>> I am a little confused about how to count part of included compo box into
>> a form...
>> I'll try to explain it better.
>> So, into a form I use 22 compo box (titled from SRS1 to SRS22) with 5
>> options for each one of them or null if unanswered.
>> These 22 combos are divided into 5 different groups
>> As the final result depends on the selected values of each separated group
>> what I need is on current form to count how many questions have been
>> answered for each group
>>
>> The groups are
>> 1st group: SRS5, SRS9, SRS12, SRS15 and SRS18 and I need to count how many
>> of them have been answered...
>> 2nd group: SRS1, SRS2, SRS8, SRS11 and SRS17
>> 3rd group: SRS4, SRS6, SRS10, SRS14 and SRS19
>> 4th group: SRS3, SRS7, SRS13, SRS16 and SRS20
>> 5th group: SRS21 and SRS22
>>
>> Have you any idea about how to count this?
>> Thank's
>>
>> /kostas
>>
>>
>>
>>
>> --
>> AccessD mailing list
>> AccessD at databaseadvisors.com
>> http://databaseadvisors.com/mailman/listinfo/accessd
>> Website: http://www.databaseadvisors.com
>>
>
>

-- 
John W. Colby



More information about the AccessD mailing list