Validation and Mandatory fields

jgalbraith

New member
Local time
Today, 00:17
Joined
Dec 3, 2009
Messages
3
Hi,

I have searched the threads but haven't found exactly what I need. You'll have to forgive the form/field names, my parent company is Italian and I am working with an existing database

Form: INSERIMENTO
Checkbox: DRAWING UPDATE REQUIRED
Date Field: DRAWING UPDATE DATE
Text Field: DRAWING INSTRUCTIONS

My goal is to make DRAWING UPDATE DATE & DRAWING INSTRUCTIONS mandatory fields when the DRAWING UPDATE REQUIRED checkbox is checked.

I found this: ([DRAWING UDPATE REQUIRED] Is Null) OR ([DRAWING UPDATE DATE] Is Not Null), But I'm not sure how to finish the rule or wether to put it in the validation rules for the check box (DRAWING UPDATE REQUIRED) or in the other fields.

Thank you very much for your assistance.

JG
 
Personally I would use the form's before update event:

http://www.baldyweb.com/BeforeUpdate.htm

I don't think a validation rule is the way to go here.

Thanks!

Ok, so using the following, how do I have it check to make sure the DRAWING UPDATE REQUIRED checkbox is checked first? If the box isn't checked, the date isn't required.

If Len(INSERIMENTO.DRAWING UPDATE DATE & vbNullString) = 0 Then
MsgBox "You need to fill out Date Required"
Cancel = True
INSERIMENTO.DRAWING UPDATE DATE.SetFocus
End If
 
Try

If Me.[DRAWING UPDATE REQUIRED] = True And Len(INSERIMENTO.DRAWING UPDATE DATE & vbNullString) = 0 Then

You will likely need to bracket your field name, given the inadvisable spaces.
 
You will likely need to bracket your field name, given the inadvisable spaces.
Probably need to bracket both fields:

Code:
If Me.[DRAWING UPDATE REQUIRED] = True And Len(INSERIMENTO.[B][[/B]DRAWING UPDATE DATE[B]][/B] & vbNullString) = 0 Then
 
Fantastic! I have one more twist thrown to me yesterday. Here is my code that works so far: (And yes, there is a spelling error in their field names :) )

Private Sub Form_BeforeUpdate(Cancel As Integer)
If Form_INSERIMENTO.DRAWING_APDATE_REQUIRED = True And Len(Form_INSERIMENTO.DRAWING_UPDATE_DATE & vbNullString) = 0 Then
MsgBox "You need to fill out Date Required"
Cancel = True
Form_INSERIMENTO.DRAWING_UPDATE_DATE.SetFocus
End If
End Sub

Now I also need to do this for a field called DRAWING_INSTRUCTIONS. Both the date and the drawing instructions need to be filled out when the Update required checkbox is marked. So how do I add a second check and have the SetFocus go to the instruction window after the date has been filled out? I tried just adding the secondary code between the End If and the End Sub, but clearly that's not right.

Thanks!
 
There are any number of ways to do this type of thing, depending on how much info you want to give the user, etc. At its simplest,

If Form_INSERIMENTO.DRAWING_APDATE_REQUIRED = True And (Len(Form_INSERIMENTO.DRAWING_UPDATE_DATE & vbNullString) = 0 OR Len(Form_INSERIMENTO.DRAWING_INSTRUCTIONS & vbNullString) = 0) Then

You can test them separately to give the user a message that specifies which need attention, set focus appropriately, etc.
 

Users who are viewing this thread

Back
Top Bottom