[AccessD] how to count selected combos in a form

Gustav Brock gustav at cactus.dk
Thu Nov 2 16:14:40 CDT 2017


Hi Kostas

It was just a skeleton. We don't know how and when or where the counting should take place, but you should be able to adopt and modify as needed.

/gustav

________________________________________
Fra: AccessD <accessd-bounces at databaseadvisors.com> på vegne af Kostas Konstantinidis <kost36 at otenet.gr>
Sendt: 2. november 2017 18:08:20
Til: 'Access Developers discussion and problem solving'
Emne: Re: [AccessD] how to count selected combos in a form

Hi Gustav,
How to use this calling it on current form?

Thanks both you and Paul

/kostas

-----Original Message-----
From: AccessD [mailto:accessd-bounces at databaseadvisors.com] On Behalf Of
Gustav Brock
Sent: Thursday, November 2, 2017 4:01 PM
To: Access Developers discussion and problem solving
<accessd at databaseadvisors.com>
Subject: Re: [AccessD] how to count selected combos in a form

Hi Kostas

You could use a loop and Select Case ...:

<code>
Public Sub CountCb()

    Const Prefix    As String = "SRS"

    Dim Value       As Variant
    Dim Item        As Integer
    Dim Count1      As Integer
    Dim Count2      As Integer
    Dim Count3      As Integer
    Dim Count4      As Integer
    Dim Count5      As Integer

    For Item = 1 To 22
        Value = Abs(Not IsNull(Me(Prefix & CStr(Item)).Value))
        Select Case Item
            Case 5, 9, 12, 15, 18
                Count1 = Count1 + Value
            Case 1, 2, 8, 11, 17
                Count2 = Count2 + Value
            Case 4, 6, 10, 14, 19
                Count3 = Count3 + Value
            Case 3, 7, 13, 16, 20
                Count4 = Count4 + Value
            Case 21, 22
                Count5 = Count5 + Value
        End Select
    Next

    Debug.Print "1:", Count1
    Debug.Print "2:", Count2
    Debug.Print "3:", Count3
    Debug.Print "4:", Count4
    Debug.Print "5:", Count5

End Sub
</code>

/gustav

-----Oprindelig meddelelse-----
Fra: AccessD [mailto:accessd-bounces at databaseadvisors.com] På vegne af
Kostas Konstantinidis
Sendt: 2. november 2017 14:39
Til: 'Access Developers discussion and problem solving'
<accessd at databaseadvisors.com>
Emne: [AccessD] how to count selected combos in a form

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

--
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com


--
AccessD mailing list
AccessD at databaseadvisors.com
http://databaseadvisors.com/mailman/listinfo/accessd
Website: http://www.databaseadvisors.com



More information about the AccessD mailing list