Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations wOOdy-Soft on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using Array Variables ina recordset

Status
Not open for further replies.

RichD

Programmer
Sep 3, 2002
150
GB
I am try to use an array in a recordset, but I keep getting the "Item not found in this collection" error, which I assune to mean it cannot interpret the variable name. here is part of my code:

dim arAccSalary as variant, arSalary as Variant, ArAccSalaryC as control

'*********store control names in arrays
arAccSalary = Array(AprSalaryAcc, MaySalaryAcc, ...etc
arSalary = Array(AprSalary, MaySalary, JunSalary, ...etc
'****************************************



'set controls to controlnames
Set ArAccSalaryC = arAccSalary(i)
Set ArNIC = ArNI(i)
Set ArSalaryC = arSalary(i)

Set RS = Me.RecordsetClone
With RS
.MoveFirst
Do Until .EOF

.Edit
For i = 0 To 11
If i = 1 Then 'first job
!ArAccSalaryC = !arSalary(i) 'This is the problem
!SalaryAcc = !Salary
Else
!ArAccSalaryC = arThisSalary(i) + !arSalary(i)
End If

I have included only the relevant part of the code. I have tried using quotes and brackets but cannot find the right syntax.

Any help greatly appreciated.

Rick
Lead Developer
 
Hi,

Maybe you could change:

RS!ArAccSalaryC = RS!arSalary(i) 'This is the problem

into:

RS!ArAccSalaryC = RS.Fields(arSalary(i))

Assuming arSalary(i) contains a string which represents a FIELD name in your RS recordset.

Let me/us know if this helped.

Bye,
Jeroen
 
Jeroen,

Thanks for your help, but I still get the same message. The array variables do represent field names in the recordsetclone.

Thanks,

Rick Lead Developer
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top