I just cant get it figured out. It's driving me crazy. Can someone help me or am I trying to do something impossible??
I have a for with multiple subforms (all equal)
When I hit the save button the procedure should check all 8 fields (txtPunt1 through 8) for empty fields. All empty fields should get a red backcolor until all values are typed into the fields.
I try to do this with following code:
Private Sub Form_BeforeUpdate(Cancel As Integer)
'Check on empty fields
Dim Counter, check
Counter = 1: check = True
Dim strPuntVeld As String
Do
Do While Counter < 7
strPuntVeld = "Form_SFAfdansen1.txtPunt" & Counter
If IsNull(strPuntVeld & ".Value") = True Then
Else
Counter = Counter + 1
End If
If Counter = 6 Or IsNull(strPuntVeld & ".Value") = True Then
check = False
MsgBox "Vul alle punten in. ", vbExclamation + vbOKOnly, ConAppName
Cancel = True
If IsNull(strPuntVeld & ".Value") = True Then
Forms("SFAfdansen1").Controls("txtPunt" & Counter).BackColor = 255
Else
Forms("SFAfdansen1").Controls("txtPunt" & Counter).BackColor = -2147483643
End If
Exit Do
End If
Loop
Loop Until check = False
end sub
It seems that the code doesnt understand the variable in the control. But I cant think of another solution
please help
Alaric
I have a for with multiple subforms (all equal)
When I hit the save button the procedure should check all 8 fields (txtPunt1 through 8) for empty fields. All empty fields should get a red backcolor until all values are typed into the fields.
I try to do this with following code:
Private Sub Form_BeforeUpdate(Cancel As Integer)
'Check on empty fields
Dim Counter, check
Counter = 1: check = True
Dim strPuntVeld As String
Do
Do While Counter < 7
strPuntVeld = "Form_SFAfdansen1.txtPunt" & Counter
If IsNull(strPuntVeld & ".Value") = True Then
Else
Counter = Counter + 1
End If
If Counter = 6 Or IsNull(strPuntVeld & ".Value") = True Then
check = False
MsgBox "Vul alle punten in. ", vbExclamation + vbOKOnly, ConAppName
Cancel = True
If IsNull(strPuntVeld & ".Value") = True Then
Forms("SFAfdansen1").Controls("txtPunt" & Counter).BackColor = 255
Else
Forms("SFAfdansen1").Controls("txtPunt" & Counter).BackColor = -2147483643
End If
Exit Do
End If
Loop
Loop Until check = False
end sub
It seems that the code doesnt understand the variable in the control. But I cant think of another solution
please help
Alaric
Last edited: