Force user to enter data

  • Thread starter Thread starter Chris
  • Start date Start date
C

Chris

I have 2 fields, the first field (text field) named
txtFinding can have only 3 response Yes, No, N/A. The
second field (memo field) is named memComments.

If the user enters a No in the txtFinding and no comment
in the memComments field I want a message to pop up that
says "You entered a No, you MUST enter a comment!!" and
then go back to the memComments field to make the user
enter a comment.
 
I have 2 fields, the first field (text field) named
txtFinding can have only 3 response Yes, No, N/A. The
second field (memo field) is named memComments.

If the user enters a No in the txtFinding and no comment
in the memComments field I want a message to pop up that
says "You entered a No, you MUST enter a comment!!" and
then go back to the memComments field to make the user
enter a comment.

Use the Form's BeforeUpdate event:

Private Sub Form_BeforeUpdate(Cancel as Integer)
If Me!txtFinding = "No" And IsNull(Me!memComments) Then
MsgBox "<chiding message>"
Cancel = True
Me!memComments.SetFocus
End If
End Sub
 
John, It did not work. Here is what I put in.

Private Sub Form_BeforeUpdate(Cancel As Integer)

If fsubFinishedAudit![txtFinding] = "No" And IsNull
(fsubFinishedAudit![memComments]) Then
MsgBox "<You entered a No, you MUST enter a comment!!>"
Cancel = True
fsubFinishedAudit!memComments.SetFocus
End If

End Sub
 
John, It did not work. Here is what I put in.

Private Sub Form_BeforeUpdate(Cancel As Integer)

If fsubFinishedAudit![txtFinding] = "No" And IsNull
(fsubFinishedAudit![memComments]) Then
MsgBox "<You entered a No, you MUST enter a comment!!>"
Cancel = True
fsubFinishedAudit!memComments.SetFocus
End If

End Sub

I gather that fsubFinishedAudit is a Subform? If so, you need to put
the code on fsubFinishedAudit's BeforeUpdate event and replace
fsubFinishedAudit! with Me!, or else with
Forms!mainformname!subformname.Form! (where subformname is the name of
the Subform control containing the form, which might or might not be
fsubFinishedAudit).
 
Thanks, got it.

-----Original Message-----
John, It did not work. Here is what I put in.

Private Sub Form_BeforeUpdate(Cancel As Integer)

If fsubFinishedAudit![txtFinding] = "No" And IsNull
(fsubFinishedAudit![memComments]) Then
MsgBox "<You entered a No, you MUST enter a comment!! "
Cancel = True
fsubFinishedAudit!memComments.SetFocus
End If

End Sub

I gather that fsubFinishedAudit is a Subform? If so, you need to put
the code on fsubFinishedAudit's BeforeUpdate event and replace
fsubFinishedAudit! with Me!, or else with
Forms!mainformname!subformname.Form! (where subformname is the name of
the Subform control containing the form, which might or might not be
fsubFinishedAudit).


.
 
Back
Top