Thank you... but it does not solve my problem!
In fact, in a batch program, I would like to trace all errors in a log file.
So, I have something like this (sorry for my english):
On error goto Error_log
Dim A as integer, B as integer,.., X as integer
Const Separator = "|"
Dim Cause_of_the_error as string, Precision_on_the_error as string
Cause_of_the_error = "Cause_1"
Precision_on_the_error = "A" & Separator & "B"
...
A = 10
...
B = 5
...
...
Cause_of_the_error = "Cause_2"
Precision_on_the_error = "C"
...
C = 10
...
...
Cause_of_the_error = "Cause_3"
Precision_on_the_error = "D" & Separator & "E" & Separator & "F"
...
D = 100
...
E = 5
...
F = 60
...
...
...
....
Error_log:
Memorize_error(..., Eval(Precision_on_the_error), ...)
Resume next
When I am in "error_log", I don't know where I come from, so it is very
difficult to konw what to replace...
> >In access I need to write something like that:
> >
[quoted text clipped - 11 lines]
>
> Eval(Replace(B, "A", A))
Albert D. Kallal - 07 Mar 2005 03:44 GMT
Well, you don't mention where the actual values are coming from?
Likely, that data has to come from somewhere (like a table).
Do NOTE that you CAN use a string variable name to reference any data field
you want. So, BEFORE you start shoving the data into variables...keep the
data in the table, or reocrdset you use for processing.
dim strWhatField as string
dim rstRecData as dao.recordset
set rstRecData = currentdb.OpenRecordset("select * from tableCustomers")
strWhatField = "LastName"
msgbox "the value of the last name field is " & rstRecData(strWhatField)
So, you can use collections here. And, in fact, you can build your own
custom collections, and use a string var again. So, really, you likely do
NOT need to use variables, and they are a poor choice here, as you can't
create new variables at runtime, and thus the idea of "substitution" for
variables don't make sense anyway from a software point of view (if you
don't know the name of the variable to be used, then how can you be use that
it exists in the first place!!).
So, since we do NOT have runtime creating of variable names, then trying to
resolve what variable name we used does NOT make sense.
You can use collections here, and for data tables, there is plenty of
workarounds to your problem here...
I worked in FoxPro (2.0 days in dos), and did like the "macro" substitution
feature. However, I worked for YEARS in ms-access, and due to the fact that
all data CAN BE referenced by string vars, then I have NEVER had to resort
to eval(), or the need to have a variable point to another variable, since
variables CAN point to data.
So, DO NOT put your log data into varalbes, but simply refernce the data in
the tables...

Signature
Albert D. Kallal (Access MVP)
Edmonton, Alberta Canada
pleaseNOOSpamKallal@msn.com
http://www.members.shaw.ca/AlbertKallal
Marshall Barton - 07 Mar 2005 06:20 GMT
>Thank you... but it does not solve my problem!
>In fact, in a batch program, I would like to trace all errors in a log file.
[quoted text clipped - 38 lines]
>When I am in "error_log", I don't know where I come from, so it is very
>difficult to konw what to replace...
You're not going to be able to do this with VBA variables.
Eval can only recognize public functions, fully qualified
form/report controls and literal values.
That's why I said to replace the variable names with their
value. If worse comes to worst, you could loop through all
the variable names replacing all of them, even they're not
used.
I don't understand what you expect the | character to
accomplish. AFAIK, that character has no use in an
expression.

Signature
Marsh
MVP [MS Access]