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 TouchToneTommy on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Loop through controls in Datarepeater

Status
Not open for further replies.

Kavius

Programmer
Apr 11, 2002
322
CA
I have a datarepeater that repeats a "question" control. I have to check a boolean property for every instance of a row in the recordset. I had read that you could use ActiveRow to set the current row, but when I do I get an error:
Code:
Variable required - cannot assign to this expression.
This is the function I have. All it is supposed to do is check to see if all the rows are valid.
Code:
private function IsValid() as boolean
  IsValid = true
  with Repeater
    for .ActiveRow = 1 to .VisibleRows
      if(.RepeatedControl.IsValid)then
        IsValid = false
        exit function
      end if
    next
  end with
end function
Any suggestions?
 
Actually, I do not know about what the function does, but in programming point of view, there is a problem with the loop itself

for .ActiveRow = 1 to .VisibleRows
if(.RepeatedControl.IsValid)then
IsValid = false
exit function
end if
next

.activerow is a property of REPEATER, it indicates the current active row, it can be set or it can return a value.

You can not use this property as an index applied in this for loop. You should modify it as follow:


private function IsValid() as boolean

Dim i as integer 'declare an index variable

IsValid = true
with Repeater
for i= 1 to .VisibleRows
.ActiveRow = i 'change the active row followed by i
if(.RepeatedControl.IsValid)then
IsValid = false
exit function
end if
next
end with
end function

hope it helps

Cheers

mdkt
 
Thank-you. That was it. Why was that it?

Activerow is a property, that much I got. But why can't a property be used as the variable in a for loop...

Oh...because it is a property, and a property can contain code. I'm thinking C where it would evaluate the condition, not VB where it assigns directly to the variable. The loop would work as a 'while' but not a 'for'. Am I right?

If I'm right...Again, thank-you. You have straightened out a misconception I didn't know I had. If not, I still don't get it (could you explain more?) Where would one begin to study Myology?
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top