Check for null fields after certain date

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

Guest

How can I write code in Before_Update that checks for the following:

If SDateField => 5/1/2005 then if DefectOneField > 0 and RMOneField is blank
then message or
if DefectTwoField > 0 and RMTwoField is blank then message or
if DefectThreeField > 0 and RMThreeField is blank then message or
on and on until DefectTenField > 0 and RMTenField is blank then message.

If SDateField < 5/1/2005 then nothing needs to be checked.

Thanks much -
 
Why do you have multiple fields named DefectXXXField? Are all of these
fields in the same table? What data are you capturing in the field?
 
Yes, I have 22 fields in the same table with the names DefectXXXField. This
database is for a manufacturer and each record is for a part where there can
be up to 22 locations where there can be a defect of a number of inches. If
there's a defect, a user needs to choose whether the defect was done by a
robot or manual. When saving the form, I need a message to appear if there
are defects greater than 0 and Robot or Manual is not selected. This only
applies to records dated after May 1, 2005.
 
Tedious.

Dim sMsg as String

IF SDateField >= #5/1/2005# then
IF DefectOneField > 0 and IsNull(RMOneField) THEN
SMsg = sMsg & vbcrlf & "Your Message Here"
End IF


IF DefectTwoField > 0 and IsNull(RMTWOField) THEN
SMsg = sMsg & vbcrlf & "Your Message Here"
END IF

....

If Len(sMsg)> 0 then
MsgBox SMsg
Cancel = True
END IF
 
Back
Top