For Each Next - I Don't Think So

dynamictiger

Registered User.
Local time
Today, 03:24
Joined
Feb 3, 2002
Messages
270
I have an unbound report that is populated entirely by code. I have this working but was playing around optimising it to cut the redundant loops out of the code and making it a bit more efficent, for slower machines.

The report is structured like:

lbl1 txt1 lblO1 tt1
lbl2 txt2 lblO2 tt2

through to 8 rows of each. lbl1 and lblO1 and tt1 are all labels, txt1 is a text field.

These names are the same as the forms that feed the information in, again the forms don't know what they are recording and the only limit is 8.

I have following code in the report that is populating lbl1 and txt1 but fails to even find lblO1, I don't understand why.

Function dpsDecideReportLabel(frm As Form, objRpt As clsWaterReportDriver)
'This module loops the report throwing down as required
'We are targeting a reduced loop count
Dim ctlRpt As Control

For Each ctlRpt In Me.Report

If Not ctlRpt.Tag = "Not" Then

MsgBox "RPTWaterTest.dpsDecideReportLabel " & ctlRpt.Name

'Debug Code added for Testing Only
Select Case Left(Right(ctlRpt.Name, 2), 1)

Case "O"

MsgBox "Yahoo " & ctlRpt.Name

Case "T"

MsgBox "Text Result"

Case "l"

MsgBox "Label " & ctlRpt.Name

Case "t"

MsgBox "TestResult " & ctlRpt.Name

End Select
'End DebugCode

Call dpsReportLabel(frm, ctlRpt, objRpt)

End If

mintLoop = mintLoop + 1

Next

End Function
 
Hi

Just a possibility but have you mis-named the label lblO1? Have you used a zero intstead?

Chris
 
Thanks for the suggewstion Chris but it is definitely O not zero. I think I know the fault, but do not understand it. It appears the fault is only replicated by using the default label with the text box. If I replace as an unbound label (not attached to text box)probelm ceases but Why???
 
Hi

I haven't a Scooby i'm afraid. But as long as you've got the answer it's not to bad. I must admit i don't like doing something if i don't know why, i've searched MS knowledge base and a couple of other forums and can't find anything.

Good Luck

Chris
 

Users who are viewing this thread

Back
Top Bottom