I would create a public sub proceedure in a Module that gets passed the control in question, and formats it accordingly. Then I would call this proceedure in the AfterUpdate and On Current events.
'Use this in the AfterUpdate event
'Begin Code---------------
Public Sub HideZeros(ByRef txt As TextBox)
If IsNumeric(txt.Text) Then
If CDbl(txt.Text)=0 Then
txt.ForeColor = txt.Backcolor
Else
txt.ForeColor=vbBlack
end If
End If
End Sub
'End Code---------------
Call this on the textbox event like:
HideZeros TextBox1 (replace name with correct one)
In the OnCurrent event use a For/Each loop:
'Begin Code---------------
Dim c As Control
For Each c In Me.Controls
If TypeOf c Is TextBox Then
HideZeros c
End If
Next c
'End Code---------------
Then on the KeyPress event just add something like:
'Begin Code---------------
TextBox1.ForeColor=vbBlack
'End Code---------------
replacing the name TextBox1 with the actual name that you have.
You could change this a little such as:
'Begin Code---------------
Public Sub HideZeros(ByRef c As Control)
If TypeOf c Is TextBox Then
If IsNumeric(c.Text) Then
If CDbl(c.Text)=0 Then
c.ForeColor = c.Backcolor
Else
c.ForeColor=vbBlack
endIf
End If
End IF
End Sub
'End Code---------------
This way in the TextBox event that this is called from you only need to call it the same for all text boxes and not have to type in the name, as in:
'Begin Code---------------
HideZeros Me.ActiveControl
'End Code---------------
If you do it this way then change the For/Each to:
'Begin Code---------------
Dim c As Control
For Each c In Me.Controls
HideZeros c
Next c
'End Code---------------
PS. I typed this out of my head with-out testing, but you should get the idea and can adjust accordingly to your needs.