Here is the code:
Public Sub TotalNetPay() 'This proc is called from proc PlaceDecimal.
'It is called from two different places within proc PlaceDecimal.
Dim StorNetMTD As Double
Dim StorNetQTD As Double
Dim StorNetYTD As Double
Dim GrossWageMTD As Double
Dim GrossWageQTD As Double
Dim GrossWageYTD As Double
Dim F4Textbox As TextBox
GrossWageMTD = txtWAMTMTD
GrossWageQTD = txtWAMTQTD
GrossWageYTD = txtWAMTYTD
For Each F4Textbox In frmF4AddEmpEarn
Select Case Left(F4Textbox.Name, 7)
Case "txtDate", "txtNetP", "txtWAMT"
'Do Nothing
Case Else
Select Case Right(F4Textbox.Name, 3)
Case "MTD"
StorNetMTD = StorNetMTD + CDbl(F4Textbox.Text)
Case "QTD"
StorNetQTD = StorNetQTD + CDbl(F4Textbox.Text)
Case "YTD"
StorNetYTD = StorNetYTD + CDbl(F4Textbox.Text)
End Select
End Select
Next
txtNetPayMTD.Text = GrossWageMTD - StorNetMTD
txtNetPayQTD.Text = GrossWageQTD - StorNetQTD
txtNetPayYTD.Text = GrossWageYTD - StorNetYTD
StorNetMTD = 0
StorNetQTD = 0
StorNetYTD = 0
End Sub
I am trying to loop thru all the txt boxes on a form and look at text for each txt box.
The FOR EACH loop gets hung up at the same place each time. The loop stops at a certain txt box and I get "Runtime Err 13", "Type mismatch" The text content is a number. It would appear that that is the only place it is getting hung up at. It stops at the "NEXT" statement.
I'm stuck. Any help is appreciated.
faxpay,
Tom
Public Sub TotalNetPay() 'This proc is called from proc PlaceDecimal.
'It is called from two different places within proc PlaceDecimal.
Dim StorNetMTD As Double
Dim StorNetQTD As Double
Dim StorNetYTD As Double
Dim GrossWageMTD As Double
Dim GrossWageQTD As Double
Dim GrossWageYTD As Double
Dim F4Textbox As TextBox
GrossWageMTD = txtWAMTMTD
GrossWageQTD = txtWAMTQTD
GrossWageYTD = txtWAMTYTD
For Each F4Textbox In frmF4AddEmpEarn
Select Case Left(F4Textbox.Name, 7)
Case "txtDate", "txtNetP", "txtWAMT"
'Do Nothing
Case Else
Select Case Right(F4Textbox.Name, 3)
Case "MTD"
StorNetMTD = StorNetMTD + CDbl(F4Textbox.Text)
Case "QTD"
StorNetQTD = StorNetQTD + CDbl(F4Textbox.Text)
Case "YTD"
StorNetYTD = StorNetYTD + CDbl(F4Textbox.Text)
End Select
End Select
Next
txtNetPayMTD.Text = GrossWageMTD - StorNetMTD
txtNetPayQTD.Text = GrossWageQTD - StorNetQTD
txtNetPayYTD.Text = GrossWageYTD - StorNetYTD
StorNetMTD = 0
StorNetQTD = 0
StorNetYTD = 0
End Sub
I am trying to loop thru all the txt boxes on a form and look at text for each txt box.
The FOR EACH loop gets hung up at the same place each time. The loop stops at a certain txt box and I get "Runtime Err 13", "Type mismatch" The text content is a number. It would appear that that is the only place it is getting hung up at. It stops at the "NEXT" statement.
I'm stuck. Any help is appreciated.
faxpay,
Tom