Eval(CONSTANT)?

J

Jack Leach

Is there a way to use Eval (or something similar) for get the value of a
constant (without having to go through a function for it)

I have a table of reports, in which I store some Where clauses to provide
various data from the same base report... in the event of some of these
clauses being over 255 chars long, I would like to store "CONST:<const name>"
and read this back from procedure that will open my reports...

Sub Report_Open(rptID As Long)
Dim strWhere as String
strWhere = GetRptClause(rptID)
If Left(strWhere, 5) = "CONST" Then
strWhere = Eval(Right(Len(strWhere) - 6))
End If
End Sub


Eval does not work (Access cannot find the expression you referred to)...
does anyone know of a way to do this, or will I have to create a function
where I pass the constant name as a string with a whole bunch of Select Case
options...

thanks!

--
Jack Leach
www.tristatemachine.com

"I haven''t failed, I''ve found ten thousand ways that don''t work."
-Thomas Edison (1847-1931)
 
D

Dirk Goldgar

Jack Leach said:
Is there a way to use Eval (or something similar) for get the value of a
constant (without having to go through a function for it)

I have a table of reports, in which I store some Where clauses to provide
various data from the same base report... in the event of some of these
clauses being over 255 chars long, I would like to store "CONST:<const
name>"
and read this back from procedure that will open my reports...

Sub Report_Open(rptID As Long)
Dim strWhere as String
strWhere = GetRptClause(rptID)
If Left(strWhere, 5) = "CONST" Then
strWhere = Eval(Right(Len(strWhere) - 6))
End If
End Sub


Eval does not work (Access cannot find the expression you referred to)...
does anyone know of a way to do this, or will I have to create a function
where I pass the constant name as a string with a whole bunch of Select
Case
options...


I'm not sure what sort of constants you're talking about, but the general
solution is either to create a separate function to return each constant
(and use those functions in you stored WHERE clauses), or else define each
constant as a public property (with a Property Get procedure) and refer to
the property in the WHERE clause.
 
J

Jack Leach

Thanks Dirk, I'll go with a seperate functions instead.

I wasn't aware you were able to refer to a public property in a Where
clause? I've had to wrap my gUSER property in a function to return this in
form/report fields (and Where clauses, though admittedly, I didn't try the
property itself, figuring that it wouldn't work).

Thanks for the advice

--
Jack Leach
www.tristatemachine.com

"I haven't failed, I've found ten thousand ways that don't work."
-Thomas Edison (1847-1931)
 
D

Dirk Goldgar

Jack Leach said:
Thanks Dirk, I'll go with a seperate functions instead.

I wasn't aware you were able to refer to a public property in a Where
clause? I've had to wrap my gUSER property in a function to return this
in
form/report fields (and Where clauses, though admittedly, I didn't try the
property itself, figuring that it wouldn't work).


You can, but you have to put parentheses -- () -- after the name, like a
function. For example,

SELECT * FROM MyTable WHERE MyField = gUser()
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top