Assign values to Variables (1 Viewer)

prao

Registered User.
Local time
Today, 07:14
Joined
Apr 16, 2001
Messages
32
Is it possible to assign values to variables dynamically.

Ex: Dim txt1 as Variant, txt2 as Variant

For i = 1 to 2
"txt" & i = i (****)
next

(****) I get the following error in this line
"Expected: Line number or label or statement or end of statement"

Can somebody give me a solution.

Thanks
 

RpbertS

Registered User.
Local time
Today, 07:14
Joined
Feb 14, 2000
Messages
93
here is some code that may help you out:
For Each i In Me![list0].ItemsSelected
If Criteria <> "" Then
Criteria = Criteria & " OR "
End If
Criteria = Criteria & "[" _
& Me![list0].ItemData(i) & "]= " _
& [TextNull] & ""
Next i

it builds criteria string from selected items in list box
 

prao

Registered User.
Local time
Today, 07:14
Joined
Apr 16, 2001
Messages
32
Hi RpbertS

Even I build this string for inserting data into a tables.

The string will look like this
2001,1,1,1,2,3,4,5,6,7 and so on.

Ex:
Insert into accounting_calendar (year,qtr,week,month,txt1,txt2,txt3,txt4 and so on ) values (2001,1,1,1,1,2,3,4 and so on)

Any idea how to build the string or assigning the values to individual variables (txt1,txt2,txt3 and so on) in a For..Loop.

Thanks



[This message has been edited by prao (edited 04-27-2001).]
 

charityg

Registered User.
Local time
Today, 07:14
Joined
Apr 17, 2001
Messages
634
You can use the field property for this. I was trying to do exactly what you are trying to. I accomplished this with
for i=1 to 20
rst!field(i)=i
next i

but it sounds like maybe you're going about something the hard way.
 

Users who are viewing this thread

Top Bottom