Results 1 to 2 of 2
  1. #1
    joebox8 is offline Novice
    Windows 7 32bit Access 2003
    Join Date
    Jun 2011
    Posts
    13

    Average of text boxes

    Hi... Up to now my basic average system was just fine.. I have 8 text boxes that HAD to be filled before any calculations could begin!

    .AVG = (.x1 + .x2 + .x3 + .x4 + .x5 + .x6 + .x7 + .x8) / 8

    Now they don't all have to be filled so how could i get the average of only the text boxes that have been filled??! Its probably very simple vb code.. AGH
    any help would be great!


    Thanks

  2. #2
    joebox8 is offline Novice
    Windows 7 32bit Access 2003
    Join Date
    Jun 2011
    Posts
    13
    Does anyone know if this this should work?? Ive tagged all my input text boxes with a "T" and put this code on the on-current property of the form.
    this code simply counts all the empty textboxes from my tagged group and that value is then 'intC'.

    Private Sub newAVG()
    Dim intC As Integer
    Dim ctrl As Control
    intC = 0

    For Each ctrl In Me.Controls
    If ctrl.Tag = "T" Then
    If IsNull(ctrl) Then
    intC = intC + 1
    End If
    End If
    Next
    End Sub



    Then for my average function I have
    .AVG = (.x1 + .x2 + .x3 + .x4 + .x5 + .x6 + .x7 + .x8) / (8 - intC)

    Am i wording it wrong or should i be calling newAVG somewhere else? If so please help..
    Thanks

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

Similar Threads

  1. Replies: 9
    Last Post: 06-04-2014, 10:45 AM
  2. Replies: 15
    Last Post: 04-01-2011, 11:41 AM
  3. Replies: 4
    Last Post: 02-14-2011, 09:11 AM
  4. Replies: 15
    Last Post: 09-18-2010, 01:19 PM
  5. joining text in text boxes
    By jjwilliams73 in forum Forms
    Replies: 1
    Last Post: 08-26-2008, 02:30 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