Loop Syntax

PC User

Registered User.
Local time
Today, 06:36
Joined
Jul 28, 2002
Messages
193
I'm having trouble with my loop counter. Its not setting the rowsource for my combobox filters. The strings with the "gstr...." are global variables. I think there's something wrong with the counter for the gstrRowSource, but I don't know how to correct it.

Code:
Private Function SetFilters()
    Dim intCounter As Integer
        For intCounter = 1 To 6
           Me("Filter" & intCounter).RowSource = gstrRowSource & intCounter
        Next
    Me.lstReports.RowSource = gstrRowSourceLst
End Function
Help would be appreciated.

Thanks,
PC
 
I'm not really following what you're doing. But I'd set some breakpoints especially on this line
"Me.lstReports.RowSource = gstrRowSourceLst"
to see what gstrRowSourceLst and gstrRowSource looks like.
 
Thanks for your reply. That command line works ok. Its the loop syntax that I think has a problem. The command line to which you are referring is out of the loop.

Thanks,
PC
 
Well, start by changing this to a SUB instead of a Function, as it doesn't appear that you are assigning a value to the function.

And, to echo James, set some breakpoints and see what the values are during runtime. What are you expecting to be in there? Are you refreshing your Form?
 
it looks like the line with the next statment is wrong. It should be as follows.

next intCounter
 
I couldn't get the loop to work, so I decided to do it the long way to get it to work even after using Debug.Print Me("Filter" & intCounter).RowSource to find the problem.
Code:
            Me.Filter1.RowSource = gstrRowSource1
            Me.Filter2.RowSource = gstrRowSource2
            Me.Filter3.RowSource = gstrRowSource3
            Me.Filter4.RowSource = gstrRowSource4
            Me.Filter5.RowSource = gstrRowSource5
            Me.Filter6.RowSource = gstrRowSource6
                Me.lstReports.RowSource = gstrRowSourceLst
Thanks,
PC
 

Users who are viewing this thread

Back
Top Bottom