I have a For Loop that takes 8 to 9 seconds to load and complete in the form load event. I am filling 199 text boxes with data from a data base. The user does this numerous times during the course of processing data.
How can I reduce the load time or is there another approach to this??? Thank you in advance for any help.
My code below:
For n = 0 To 199 Step 10 'Step 10 provides index for 1st column text box for ea row.
If objSource.adoRsPyrlCalc2.EOF = True Then Exit For
Select Case n 'Numbers below are indexes for 1st column of text boxes.
Case 0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190
i = n 'Load fields from recordset into text boxes. Below loads
'one row.
txt1(i).Text = objSource.adoRsPyrlCalc2!WAGENAME
i = i + 1
txt1(i).Text = objSource.adoRsPyrlCalc2!WageNo
'Load array and advance index for use in proc CalcGross and
'proc PostWageTypes.
WageNos(A) = objSource.adoRsPyrlCalc2!WageNo
If A = 20 Then 'If this is twentieth wage then no more WageNos to store.
'Do not increment array index for next array WageNos.
Else
A = A + 1 'Do increment A if A is less than 20. If this is last
'wage being loaded then A will be 1 larger than
'last wage number loaded into array WageNos.
End If
i = i + 1
txt1(i).Text = objSource.adoRsPyrlCalc2!DEPT
i = i + 1
'txt1(i).Text = objSource.adoRsPyrlCalc2! (Future Use)
i = i + 1
txt1(i).Text = objSource.adoRsPyrlCalc2!WRATE
'Pass WAGENO and i to procedure PostWageTypes.
PostWageTypes objSource.adoRsPyrlCalc2!WageNo, i
'This bookmarks the record for each row of textboxes by using the
'Txt1 index of the WRATE textbox as an item(index) of the
'bookmark array to bookmark each record.
'The Txt1 WRATE Gotfocus event then calls the bookmark to make
'that row of textboxes the current record and then binds the
'WRATE textbox so that the user can then edit the WRATE textbox.
BkMrk(i) = objSource.adoRsPyrlCalc2.Bookmark
i = i + 5
txt1(i).Text = objSource.adoRsPyrlCalc2!YTD_AMT
End Select
objSource.adoRsPyrlCalc2.MoveNext 'Iterate through all wages for employee.
Next n
TNN, Tom
TNPAYROLL@AOL.COM
TOM
How can I reduce the load time or is there another approach to this??? Thank you in advance for any help.
My code below:
For n = 0 To 199 Step 10 'Step 10 provides index for 1st column text box for ea row.
If objSource.adoRsPyrlCalc2.EOF = True Then Exit For
Select Case n 'Numbers below are indexes for 1st column of text boxes.
Case 0, 10, 20, 30, 40, 50, 60, 70, 80, 90, 100, 110, 120, 130, 140, 150, 160, 170, 180, 190
i = n 'Load fields from recordset into text boxes. Below loads
'one row.
txt1(i).Text = objSource.adoRsPyrlCalc2!WAGENAME
i = i + 1
txt1(i).Text = objSource.adoRsPyrlCalc2!WageNo
'Load array and advance index for use in proc CalcGross and
'proc PostWageTypes.
WageNos(A) = objSource.adoRsPyrlCalc2!WageNo
If A = 20 Then 'If this is twentieth wage then no more WageNos to store.
'Do not increment array index for next array WageNos.
Else
A = A + 1 'Do increment A if A is less than 20. If this is last
'wage being loaded then A will be 1 larger than
'last wage number loaded into array WageNos.
End If
i = i + 1
txt1(i).Text = objSource.adoRsPyrlCalc2!DEPT
i = i + 1
'txt1(i).Text = objSource.adoRsPyrlCalc2! (Future Use)
i = i + 1
txt1(i).Text = objSource.adoRsPyrlCalc2!WRATE
'Pass WAGENO and i to procedure PostWageTypes.
PostWageTypes objSource.adoRsPyrlCalc2!WageNo, i
'This bookmarks the record for each row of textboxes by using the
'Txt1 index of the WRATE textbox as an item(index) of the
'bookmark array to bookmark each record.
'The Txt1 WRATE Gotfocus event then calls the bookmark to make
'that row of textboxes the current record and then binds the
'WRATE textbox so that the user can then edit the WRATE textbox.
BkMrk(i) = objSource.adoRsPyrlCalc2.Bookmark
i = i + 5
txt1(i).Text = objSource.adoRsPyrlCalc2!YTD_AMT
End Select
objSource.adoRsPyrlCalc2.MoveNext 'Iterate through all wages for employee.
Next n
TNN, Tom
TNPAYROLL@AOL.COM
TOM