Loop Syntax (1 Viewer)

PC User

Registered User.
Local time
Today, 14:29
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
 

James Deckert

Continuing to Learn
Local time
Today, 16:29
Joined
Oct 6, 2005
Messages
189
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.
 

PC User

Registered User.
Local time
Today, 14:29
Joined
Jul 28, 2002
Messages
193
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
 

pdx_man

Just trying to help
Local time
Today, 14:29
Joined
Jan 23, 2001
Messages
1,347
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?
 

FireStrike

Registered User.
Local time
Today, 17:29
Joined
Jul 14, 2006
Messages
69
it looks like the line with the next statment is wrong. It should be as follows.

next intCounter
 

PC User

Registered User.
Local time
Today, 14:29
Joined
Jul 28, 2002
Messages
193
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

Top Bottom