[AccessD] Form Validation

Ryan W wrwehler at gmail.com
Sat Oct 29 16:48:29 CDT 2022

I thought I had emailed about this before but I cannot find it.  Maybe it
got lost somewhere along the way or I thought about emailing and never did.

I've got a form we use to log in client data, there are some extra fields
that are NOT required by every client so I can't put backend constraints on

I was wondering if I could write a table such as:

ClientID varchar(100)
Project varchar(100)
FieldToScrutinize varchar(100)
FunctionToEval varchar(255)
ForeColor varchar(50)
BackColor varchar(50)

So lets say we have ClientA, Project B, FieldToScrutinize is "ExtraFld1"

FunctionToEval would be something like Len(me!extrafld1) = 0

So then in the form code we have something like

rst = currentdb.openrecordset("SELECT * FROM ValidationRules WHERE ClientID
= '" & me.ClientID & "'")

do until rst.eof
   if Eval(rst!FunctionToEval) = false then
  me(FieldToScrutinize).BackColor = rst!BackColor
  me(FieldToSTrutinize).ForeColor = rst!ForeColor
   end if

I guess my question is, will EVAL work in that manner?  That way all my
validation rules for these specific clients can be managed in a table
rather than adding code and having to distribute a new FE when rules are

More information about the AccessD mailing list