How?? "comments" field required if "code" field =>20 (deadline nea

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I'm creating a form and need to make the "comments" field required if the
"code" field is =>20. I appreciate suggestions! Deadline Monster is lurking!

User enters the job processing endcode value (numeric) into the "code"
field. If the endcode is =>20, comments are required.

(P.S. I don't know VB)

Thanks!
Star
 
1. Open your table in design view.
2. Open the Properties box (View menu.)
3. Beside the Validation Rule in the Properties box, enter this:
(
Code:
 Is Null) OR ([code] < 20) OR ([comments] Is Not Null)

The rule is satisfied if you leave code blank, or if code has a value less
than 20. Otherwise the rule is only satisfied if comments is not blank.

Note that you must use the rule in the Properties box, not the one in the
lower pane of table design. More info:
http://allenbrowne.com/ValidationRule.html
 
Well, I guess it's time you learned VBA! <g>

Select your form, and look in the Properties window. Find the BeforeUpdate
event, set it to [Event Procedure] (it's a choice in the combo box), then
click on the ellipsis (...) to the right of the property.

That'll take you into the VB Editor, in the middle of something like:

Private Sub Form_BeforeUpdate(Cancel As Integer)

End Sub

Now, assuming that the fields on your form really are named "Endcode" and
"Comments", add the following into that block of code:

Private Sub Form_BeforeUpdate(Cancel As Integer)

If Me.Endcode >= 20 Then
If Len(Me.Comments & "") = 0 Then
MsgBox "You must input a comment.", _
vbOkOnly + vbCritical
Cancel = True
End If
End If

End Sub

(change the references to Me.Endcode and Me.Comments about if your names are
different)
 
Thank you! Worked beautifully!

Allen Browne said:
1. Open your table in design view.
2. Open the Properties box (View menu.)
3. Beside the Validation Rule in the Properties box, enter this:
(
Code:
 Is Null) OR ([code] < 20) OR ([comments] Is Not Null)

The rule is satisfied if you leave code blank, or if code has a value less
than 20. Otherwise the rule is only satisfied if comments is not blank.

Note that you must use the rule in the Properties box, not the one in the
lower pane of table design. More info:
http://allenbrowne.com/ValidationRule.html

--
Allen Browne - Microsoft MVP.  Perth, Western Australia
Tips for Access users - http://allenbrowne.com/tips.html
Reply to group, rather than allenbrowne at mvps dot org.

[QUOTE="StarT"]
I'm creating a form and need to make the "comments" field required if the
"code" field is =>20. I appreciate suggestions! Deadline Monster is
lurking!

User enters the job processing endcode value (numeric) into the "code"
field. If the endcode is =>20, comments are required.

(P.S. I don't know VB)

Thanks!
Star[/QUOTE]
[/QUOTE]
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top