Form/ Table validation rule - not working
Hello Scott, on my form I have a combo box cmbMgSO4 with values “Yes”; “No” If the user selects Yes, then the text box txtExtra must not be null. The user must provide the dose. For this, I have the validation rule:
IIf([More MgSO4?]=”Yes”, Not IsNull([extra dosage]), IsNull([extra dosage]))
This works until you violate it. Then after you correct the error, the validation text message wouldn’t go away. I understand that it is better to put the validation rule on the form using VB but I need assistance with the below code please. I wrote this code in the AfterUpdate event of [extra dosage] – i.e. the textbox txtExtra but it has bugs. Could you tell me what is wrong with it? Private Sub txtExtra_AfterUpdate()
If [More MgSO4?] = “Yes” Then
If Len([extra dosage].Text & vbNullString) = 0 Then
MsgBox “Please provide the extra dose!”, vbOK + vbExclamation
Else
[extra dosage].Text = Me.txtextra.Text
Len([extra dosage].Text) > 0
End If
Else Len([extra dosage].Text) = 0
End If
End Sub