Eval("Name of Field")

M

MDB-HZA

A column in a query:
Data: Eval(FieldName())

In a general Module:
Public Sub FieldName() As String
FieldName = "Name of Field"
End Sub

when run, the query should EVALUATE the name of the field returned in the
query and look up the value of that field for each record. Instead it puts
"Name of Field" in each record. Would not the purpose of evaluate be to
change from a string to code?
 
G

Gijs Beukenoot

Na rijp beraad schreef MDB-HZA :
A column in a query:
Data: Eval(FieldName())

In a general Module:
Public Sub FieldName() As String
FieldName = "Name of Field"
End Sub

when run, the query should EVALUATE the name of the field returned in the
query and look up the value of that field for each record. Instead it puts
"Name of Field" in each record. Would not the purpose of evaluate be to
change from a string to code?

It's doing exactly as you code. The function returns "Name of Field" so
that's what you get in your query... I'm not sure what you'd expect it
to return, please explain a little bit further...
 
J

Jeff Boyce

The Eval() function attempts to determine the value of an expression -- see
Access HELP for examples. When you use Eval(FieldName()), it appears you
are telling Access that the field name is an expression.

Are you trying to determine what is IN the field with that field name? If
so, you could just use the field name in your query...
 
Top