Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to create this COUNT field?

Status
Not open for further replies.

TracyYu

Technical User
Feb 9, 2004
17
US
I have the following field: Day_1, Day_2, Day_3, ... Day_10 their value can be: X, Y, or Z

Then I have a field: all_X this field is a count of total number of X's entered in the Day_# fields.

Anyone has an idea how to do that? X-)

Thanks in advance.

p.s.
all_X field is locked, so no data can be entered.
 
I created a command button on the form and an integer to keep track of the count.

Code:
Private Sub cmdCount_Click()
    Dim intCount As Integer
    
    intCount = 0
    
    If Day_1 = "X" Then
        intCount = intCount + 1
    End If
    If Day_2 = "X" Then
        intCount = intCount + 1
    End If
    If Day_3 = "X" Then
        intCount = intCount + 1
    End If
    If Day_4 = "X" Then
        intCount = intCount + 1
    End If
   If Day_5 = "X" Then
        intCount = intCount + 1
    End If
    If Day_6 = "X" Then
        intCount = intCount + 1
    End If
    If Day_7 = "X" Then
        intCount = intCount + 1
    End If
    If Day_8 = "X" Then
        intCount = intCount + 1
    End If
    If Day_9 = "X" Then
        intCount = intCount + 1
    End If
    If Day_10 = "X" Then
        intCount = intCount + 1
    End If

    
    txtCount = intCount
End Sub
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top