Eval Function

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • galexinc
    New Member
    • Aug 2008
    • 1

    Eval Function

    Hi, I’m accountant by profession, so database development is a new field for me, but I’m very motivated.
    Please let me know if anybody could explain what Eval function does and how to use it. I’ve read the help topic on MC site, but couldn’t make sense of it.
    Specifically, they don’t explain how the syntax works.
    Also, the logic behind this function is not clear. In other words: for what kind of problems it was created? Thanks in advance.
  • NeoPa
    Recognized Expert Moderator MVP
    • Oct 2006
    • 32656

    #2
    Eval is provided for where logic, or functionality needs to be derived from some sort of variable source.

    Consider the following (I know this example can be done more easily without Eval() but simply as an illustration) :
    You have an field ([TranType]) in a record that could evaluate to either of the strings "Invoice" or "Credit". Another field is [TranVal]. You need to determine the value of the transaction record within a query, so the following would be an option for you :
    Code:
    SELECT ...
           Eval('[TranVal]*' & IIf([TranType]='Invoice','+','-') & '1') As [LineVal]
    FROM ...
    Does this help?

    Comment

    Working...