[AccessD] Form Validation
Ryan W
wrwehler at gmail.com
Sat Oct 29 19:23:32 CDT 2022
By the way:
I did just test Eval(Len(Me!Field)>0) in a little test DB here at home and
it did spit out the right result, so it does seem even though Eval may not
know about the "Me" object, Len still does.
On Sat, Oct 29, 2022 at 6:29 PM Stuart McLachlan <stuart at lexacorp.com.pg>
wrote:
> Doh!
>
> > strFldVal = Me(strFld)
>
> should, of course, be:
>
> > strFldVal = Me(rst.FieldToScrutinize)
>
> (that's what you get when you quickly edit test code to align with the OP)
>
> On 30 Oct 2022 at 9:07, Stuart McLachlan wrote:
>
> > First impression:
> > Colours are 4byte integers (LONGs) (with the top byte unused for RGB
> > colours)
> > (And Project and Client keys as varchars() is a bit on the nose too :)
> > )
> >
> > That said - Eval doesn't recognise "me".
> > You'll need to do something like:
> >
> > 'Record in table:
> > FieldToScrutinize "ExtraFld1"
> > FunctiomToEval = "Len(<fldval>) > 0"
> >
> > Then in your function
> > 'Create Eval string
> > strFldVal = Me(strFld)
> > strEval = Replace(rst.FunctionToEval, "<fldval>",
> > rst.FieldToScrutinize) If Eval(strEval) ....
> >
> >
> >
> >
> >
> > On 29 Oct 2022 at 16:48, Ryan W wrote:
> >
> > > 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 them.
> > >
> > > 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
> > > rst.MoveNext
> > > loop
> > >
> > > 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 modified? -- AccessD mailing list
> > > AccessD at databaseadvisors.com
> > > https://databaseadvisors.com/mailman/listinfo/accessd Website:
> > > http://www.databaseadvisors.com
> > >
> >
> >
> > --
> > AccessD mailing list
> > AccessD at databaseadvisors.com
> > https://databaseadvisors.com/mailman/listinfo/accessd
> > Website: http://www.databaseadvisors.com
> >
>
>
> --
> AccessD mailing list
> AccessD at databaseadvisors.com
> https://databaseadvisors.com/mailman/listinfo/accessd
> Website: http://www.databaseadvisors.com
>
More information about the AccessD
mailing list