Trigger all validation rules before submitting a form

  • Thread starter Thread starter Deleted member 141518
  • Start date Start date
D

Deleted member 141518

Guest
Hello,

I have a form with several fields(/combox) and cross-field validation rules.

My problem is that some of those fields may end up having a value (usually the default one) that is inconsistent with their validation rule but, not being touched by the user, they never trigger the rule validation check.

Is there a way to trigger all the validation rules before inserting/modifying the record?
 
I do my checks via code (not in the field property)
Easier to change...

usage:
if IsValidForm() then docmd.openquery "qaAddNewRecord"

Code:
Private Function IsValidForm() As Boolean
Dim vMsg
Select Case True
   Case IsNull(dtpWeekOf)
      vMsg = "Date field missing"
   Case IsNull(cboUser)
      vMsg = "Teacher name is missing"
   Case IsNull(cboSubj)
      vMsg = "Subject field is missing"
End Select
If vMsg <> "" Then MsgBox vMsg, vbCritical, "Required Field"
IsValidForm = vMsg = ""
End Function
 
I do my checks via code (not in the field property)
Easier to change...

usage:
if IsValidForm() then docmd.openquery "qaAddNewRecord"

Code:
Private Function IsValidForm() As Boolean
Dim vMsg
Select Case True
   Case IsNull(dtpWeekOf)
      vMsg = "Date field missing"
   Case IsNull(cboUser)
      vMsg = "Teacher name is missing"
   Case IsNull(cboSubj)
      vMsg = "Subject field is missing"
End Select
If vMsg <> "" Then MsgBox vMsg, vbCritical, "Required Field"
IsValidForm = vMsg = ""
End Function

Yes, thank you, I will as well work with beforeUpdate, basically re-writing all the rules (now their opposites for blocking possible errors) in VBA.

At this point I could have as well avoided to lose time writing the rules... Thought there was a faster and easier solution.

Thank you
 

Users who are viewing this thread

Back
Top Bottom