Results 1 to 5 of 5
  1. #1
    wirekoh is offline Novice
    Windows 8 Access 2010 32bit
    Join Date
    Feb 2013
    Posts
    2

    summing comboboxes values to display a number in a text field.

    i have 25 combo boxes on my form with the same two row source values "MENTIONED" and "NOT MENTIONED". I want to display the total number "MENTIONED" selected within the 25 combo boxes to display in a text box named "TOTAL_SCORE".
    How can i sum the number of "MENTIONED" selected within the 25 combo boxes to display on the text boxes. please help me.....


  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,892
    Maybe:

    =IIf(combo1="MENTIONED",1,0) + IIf(combo2="MENTIONED",1,0) + IIf(combo3="MENTIONED",1,0) + ...

    That will be a very long expression, probably too long for the allowed length. Might have to build a custom function to accomplish.

    Why do you need this on form?

    Why do you have 25 comboboxes choosing the same data?
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    Missinglinq's Avatar
    Missinglinq is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    May 2012
    Location
    Richmond (Virginia, not North Yorkshire!)
    Posts
    3,018
    Replacing txtMentioned and txtNotMentioned with the actual names of the Textboxes you want to display the results (and these Controls should not be Bound, as they're calculated results, and should simply be re-calculated, as needed) and place this code in the Form's Code Module:
    Code:
    Public Sub Total_CBOs()
    
     Dim ctl As Control
     Dim Mentioned As Integer
     Dim NotMentioned As Integer
    
     Mentioned = 0
     NotMentioned = 0
    
     For Each ctl In Me.Controls
       If TypeOf ctl Is ComboBox Then
         If ctl = "Mentioned" Then Mentioned = Mentioned + 1
         If ctl = "NoT Mentioned" Then NotMentioned = NotMentioned + 1
       End If
     Next ctl
    
    Me.txtMentioned = Mentioned
    Me.txtNotMentioned = NotMentioned
    
    End Sub


    Now, in the AfterUpdate event of each Combobox, place this code:

    Code:
    Call Total_CBOs


    In order to have the totals show, as you move from Record-to-Record, place the same code in the Form_Current event of the Form.

    Linq ;0)>
    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

  4. #4
    wirekoh is offline Novice
    Windows 8 Access 2010 32bit
    Join Date
    Feb 2013
    Posts
    2
    Quote Originally Posted by June7 View Post
    Maybe:

    =IIf(combo1="MENTIONED",1,0) + IIf(combo2="MENTIONED",1,0) + IIf(combo3="MENTIONED",1,0) + ...

    That will be a very long expression, probably too long for the allowed length. Might have to build a custom function to accomplish.

    Why do you need this on form?

    Why do you have 25 comboboxes choosing the same data?
    thank you for your reply very helpful. About 25 comboboxes with the same row source "MENTIONED and "NOT MENTIONED"?. I have 25 questions asking patients knowledge about the effect and causes of malaria. So if the patients has knowledge about the asked question the answer to the question is MENTIONED and if no response or no knowledge the answer is NOT MENTIONED. That's why i am having 25 comboboxes. I know could have used check boxes buat i preferred to use the comboboxes for some reasons.Thank you again.

    I am having another problem again hoping you can help. I am conducting a survey on malaria which patients go through the following processes ......1. SCREENING 2. ENROLMENT 3. FOLLOW UP 4. DELIVERY
    SO i am having 4 Tables "tbl_Screening", "tbl_Enrolment, "tbl_Follow_up" and "tbl_Delivery". I all so have 4 forms also in respect to the 4 processes named above.
    I have a primary key being patients "study_id number" on all the Tables. I have the following fields "interviewer code" and "patient's initials" which is also on all Tables hence appearing on all the 4 forms too. If you understand my survey, now my question is....

    When i first fill the following fields "study_id number", "patient's initials", "interviewer code" on the SCREENING form, how can i pull these information onto the ENROLMENT form, FOLLOW UP form and DELIVERY form since there all the same to that already entered. please help me..

  5. #5
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,892
    Sounds like you need to have the 4 tables as subforms on a main form bound to the parent study table. Use a tab control and place each subform on a page of the tab control.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 1
    Last Post: 06-29-2012, 01:22 PM
  2. Replies: 3
    Last Post: 05-29-2012, 04:47 PM
  3. pulling text values into FK number column
    By REBBROWN in forum Database Design
    Replies: 2
    Last Post: 08-30-2010, 05:04 PM
  4. Issue summing two field values
    By w2vijay in forum Reports
    Replies: 4
    Last Post: 02-10-2010, 01:53 AM
  5. Replies: 3
    Last Post: 10-23-2009, 05:03 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums