Variable In-line Substitution

iknowkungfu

Registered User.
Local time
Today, 23:14
Joined
Jan 17, 2006
Messages
24
I think the title describes what I want to do, but:

For example, I want to create multiple recordsets with names created dynamically.
Code:
For intX = 0 to 5
	Dim objRST(intX) As Recordset
	intX = intX + 1
Next

Creating 6 recordsets named
objRST0
...
objRST5

I'd then want to process these recordsets in the same way.

So what you are doing is putting the value of a variable into the code as it is executed.
 
IKKF, No, I don't believe you can alter a variable's name, programmatically.

IKKF, excuse the criticism but, BUT, YOUR CODE IS COMPLETELY ERRONEOUS!!!

Not one line makes sense. Maybe one "intX = intX + 1", and it's redundant

If I were you, I would use ONE recordset object, and reset it, 6 X.

Dim rec As ADODB.Recordset, varTable As Variant

Set Rec = New ADODB.Recordset

varTable = Array("tblCountry","tblContact","tblEmployee","tbldepartment","SELECT txtEmployee FROM tblEmployee WHERE txtName Like '[A-F]*'","tblCade")

For x = 0 To 5
rec.Open varTable(x),CurrentProject.Connection,adDynamic, adLockOptimistic

rec!... = hjjhjj
rec.Close: Set rec = Nothing
Next x
 
Incrementing the counter... old Java habits die hard.

4 lines of code, 1 was redundant, 2 are fine and the other was TRYING to demonstrate what I was trying to do. That's hardly "completely erroneous".

Thanks for your help.
 
...yes, you're right. A little exagerated on my part.
(the "demonstration", may have thrown me off a bit).
 

Users who are viewing this thread

Back
Top Bottom