Assigning field values to variable
: Here's my problem: I have a Dynaset of 1 record whose fields I am
: trying to map to variables. This works fine in situations like this:
: MyName = MyDynaset!Name
: MyAge = MyDynaset!Age
: But there are fields in the database that are called Question_1,
: Question_2, Question_3 and so on. I want to map them to a string array
: called MyQuestion.
: I figured a loop would be the most efficient way of retrieving these
: values but I can't figure out how to increment the field name. If I do
: something like this:
: for i = 1 to 10
: Mystring = "MyDynaset!Question_" & i
: MyQuestion(i) = Mystring
: next
: The value of MyQuestion(1) = "Question_1" and so on (not the value of
: the Question_1 field). How can I increment the name of the field and
: use that in my expression?
: Russ Posey
Well, your problem with doing it this way is that the "" around your
dynaset variable name just makes it a string which is then assigned to
Mystring.
I'v encountered similar situations on several occasions. The problem is
that there is no good way to access a different variable each time
through the loop. One possibility, though it very cumbersome as far as
code, is to use a big nested IF to select different varibles based i.
However this is only practical if you know how many of these Question_
there are, BUT, if you know how many there are, you'd be better off just
making a long series of assignments and skipping the loop idea all togehter.
--
--Russell J Brasser-----------------------"Nothing is Impossible!"------------