Results 1 to 4 of 4
  1. #1
    markjkubicki's Avatar
    markjkubicki is offline Competent Performer
    Windows 10 Access 2013 64bit
    Join Date
    Jul 2010
    Location
    Fire Island Pines, NY
    Posts
    496

    can comparison criteria be saved in a table?

    i have a table that i use to store control names, comparison criteria, related record I.D.s, field names, etc.



    the field names would be: Note_Cntrl, Note_Criteria, Note_ID, Note_Field, etc...

    (the different fields are used in different places, in different combinations throughout the project; this is to reduce redundancy in code)



    Typical code using these values would be like this:

    if you're at control ___, check field ___, in table ___, for this criterion ___



    for most records, the criteria is a simple:
    ...True or False (-1 or 0)
    for a select few, the criteria is more difficult:
    ... InStr(Nz(Forms!frmSpec.controls(strControl_Name), ""), "0-10") > 0 And Forms!frmSpec.chkDimmableYN


    the code that this info is fed into would be:
    Code:
              strNote_Control = gsRst! Note_Cntrl
              strNote_Criteria = gsRST!Note_Criteria
              if Forms!frmSpec.Controls(strNote_Cntrl) = strNote_Criteria then
                    ... (do something)
    This work fine for Boolean criteria;

    However, for the more complicated criteria, it’s comparing against the criteria ***as a sting value***, not as an evaluation of that criteria


    • How can I deal with the eval of the more difficult criteria?
    • Is this an effective approach ?


    As always, with thnx in adv
    ance,

    m.

  2. #2
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,430
    store the complete criteria

    InStr(Nz(Forms!frmSpec.controls(strControl_Name), ""), "0-10") > 0

    will evaluate to true/false

    could also be written as

    Nz(Forms!frmSpec.controls(strControl_Name),"") Like "*0-10*"

  3. #3
    markjkubicki's Avatar
    markjkubicki is offline Competent Performer
    Windows 10 Access 2013 64bit
    Join Date
    Jul 2010
    Location
    Fire Island Pines, NY
    Posts
    496
    thinking to myself... "how do i get this to EVALuate the string as a formula";

    so... with no knowledge of, i tried EVAL()
    TaDa!!!!
    exactly what i was looking for

    also simplified the criteria formulas... (like stop looking for a value that is in the same table/record as the formula being evaluated, just include the value in in the formula first place...)
    (but that's an aside, the answer i was looking for: EVAL() !)

  4. #4
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,430
    actually I thought you were already using the Eval function - otherwise would have mentioned it

    good luck!

Please reply to this thread with any new information or opinions.

Similar Threads

  1. data comparison within same table
    By harryklein in forum Queries
    Replies: 4
    Last Post: 07-19-2019, 02:26 AM
  2. Replies: 2
    Last Post: 08-08-2016, 09:02 AM
  3. Table creation for comparison
    By Zealotwraith in forum Access
    Replies: 11
    Last Post: 09-03-2013, 06:41 AM
  4. Date comparison syntax in query criteria
    By SyntaxSocialist in forum Queries
    Replies: 3
    Last Post: 04-09-2013, 08:39 AM
  5. Table field comparison
    By shabar in forum Queries
    Replies: 3
    Last Post: 01-31-2013, 02:09 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums