Kind of confusing...
You say
Originally Posted by
BigJohn89
What I am trying to do is to count the number of non-blank textboxes and put the quantity in another label.
The the code is
Code:
<snip>
For x = 1 To 60
' If IsNull(Me("slot_" & x)) Or (Me("slot_" & x)) = "" Then
If (Me("slot_" & x) & "") = "" Then ' If slot is empty (does the same thing as the line above)
intC = intC + 1 ' Add 1 to the variable (increase the count of empty 'slots')
txtCount = intC ' is "txtCount" a LABEL or a text box control???
End If
Next
End Sub
You say you want to count the NON-BLANK 'slots', but you are counting the BLANK 'slots'.
If you want to put the quantity into a Label, you would need to update the Caption property of a Label.
This updates the NON-BLANK slot count (I tested only using two slots)
Code:
Private Sub Slot_1_AfterUpdate()
Call CountSlotsFull
End Sub
Private Sub Slot_2_AfterUpdate()
Call CountSlotsFull
End Sub
Private Sub CountSlotsFull()
Dim x As Integer
Dim intC As Integer
intC = 0
For x = 1 To 2
If Len(Trim(Me("slot_" & x) & "")) > 0 Then
intC = intC + 1
End If
Next
Me.txtCount = intC '<< in this case, txtCount is a control, not a label
End Sub