[AccessD] Form Validation
Ryan W
wrwehler at gmail.com
Sat Oct 29 20:11:38 CDT 2022
I did but I don't see where you used strFldVal after you set it to
Me(rst.FieldToScrutinize) which is just going to set strFldVal to the value
of the scrutinized field (which will still require to be wrapped in quotes,
as I found in a follow-up email)
On Sat, Oct 29, 2022 at 8:05 PM Stuart McLachlan <stuart at lexacorp.com.pg>
wrote:
> Did you see my subsequent correction
> > strFldVal = Me(strFld)
> should, of course, be:
> > strFldVal = Me(rst.FieldToScrutinize)
>
> It looks like you have put quotes around the thrid Replace parameter.
> i.e.
> strEval = Replace(rst.FunctionToEval, "<fldval>","theActualFiledValue")
> rather than
> strEval = Replace(rst.FunctionToEval, "<fldval>",theActualFiledValue)
>
>
> On 29 Oct 2022 at 19:54, Ryan W wrote:
>
> > Having a bit of a snafu on this. When I do this the strEval turns into
> > Len(theActualFieldValue)>0
> >
> > so I get an error "cannot find the name theActualFieldValue you
> > entered in the expression" message... I assume because it's thinking
> > theActualFieldValue should be some sort of object to evaluate since
> > it's not wrapped in quotes?
> >
> >
> > > 'Create Eval string
> > >strFldVal = Me(strFld)
> > >strEval = Replace(rst.FunctionToEval, "<fldval>",
> > >rst.FieldToScrutinize) If Eval(strEval) ....
> >
> > On Sat, Oct 29, 2022 at 6:07 PM Stuart McLachlan
> > <stuart at lexacorp.com.pg> 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
> >
>
>
> --
> 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