468,765 Members | 1,430 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,765 developers. It's quick & easy.

Listbox works and then it doesn't

I have an app in which users are displayed a list of mutual fund from which
they can choose. There is a listbox embedded in a two-tabbed notebook
control. When the form is initally opened, the listbox loads info:

Private Sub Form_Open(Cancel As Integer)
TabControl.Value = 0
Tab_Label1.Caption = "Select Alternatives from the Select List"
FundAlternativesList.RowSource = "Load_Select_Alternatives_Form"
Call Highlight_Defaults
End Sub

The RowSource "Load_Select_Alternatives_Form" is a query that populates the
listbox. Then I have this sub to change the values displayed depending upon
which tab is selected:

Sub TabControl_Change()
If TabControl.Value = 0 Then
FundAlternativesList.RowSource = "Load_Select_Alternatives_Form"
FundAlternativesList.ColumnCount = 3
Tab_Label1.Caption = "Select Alternatives from the Select List"
Call Highlight_Defaults
Else
FundAlternativesList.RowSource = "Select_Gap_Funds"
FundAlternativesList.ColumnCount = 1
Tab_Label1.Caption = "Select Alternatives from the Revenue Sharing
List"
End If
End Sub

This works fine too. But the whole point of the two tabs is to allow one to
choose funds from two different sources. If someone is on tab #1 and clicks
a button to run a sub based on the funds that are selected, that sub works
fine. But if they then click on tab #2 immediately after that is finished
running, the listbox is empty.

Reclicking on tab1 and then tab2 refreshes it properly, but that is not the
way it is supposed to work. I have stepped through the code and watched it
go right through the command that should refresh the data, but nothing
happens.

Can anyone tell me why this is occurring?
Nov 12 '05 #1
7 1753
After setting/changing the rowsource of the listbox/combo box try requerying
it (i.e.. Me.mylistbox.Requery)

--
Reggie

www.smittysinet.com
----------
"Colleyville Alan" <ae***********@nospam.comcast.net> wrote in message
news:MXBoc.36511$z06.5767180@attbi_s01...
I have an app in which users are displayed a list of mutual fund from which they can choose. There is a listbox embedded in a two-tabbed notebook
control. When the form is initally opened, the listbox loads info:

Private Sub Form_Open(Cancel As Integer)
TabControl.Value = 0
Tab_Label1.Caption = "Select Alternatives from the Select List"
FundAlternativesList.RowSource = "Load_Select_Alternatives_Form"
Call Highlight_Defaults
End Sub

The RowSource "Load_Select_Alternatives_Form" is a query that populates the listbox. Then I have this sub to change the values displayed depending upon which tab is selected:

Sub TabControl_Change()
If TabControl.Value = 0 Then
FundAlternativesList.RowSource = "Load_Select_Alternatives_Form"
FundAlternativesList.ColumnCount = 3
Tab_Label1.Caption = "Select Alternatives from the Select List"
Call Highlight_Defaults
Else
FundAlternativesList.RowSource = "Select_Gap_Funds"
FundAlternativesList.ColumnCount = 1
Tab_Label1.Caption = "Select Alternatives from the Revenue Sharing
List"
End If
End Sub

This works fine too. But the whole point of the two tabs is to allow one to choose funds from two different sources. If someone is on tab #1 and clicks a button to run a sub based on the funds that are selected, that sub works
fine. But if they then click on tab #2 immediately after that is finished
running, the listbox is empty.

Reclicking on tab1 and then tab2 refreshes it properly, but that is not the way it is supposed to work. I have stepped through the code and watched it go right through the command that should refresh the data, but nothing
happens.

Can anyone tell me why this is occurring?

Nov 12 '05 #2
> After setting/changing the rowsource of the listbox/combo box try
requerying
it (i.e.. Me.mylistbox.Requery)
And if that doesn't work, refresh the count:

v = me.mylistbox.ListCount

Getting the count actually forces it to collect all of the rows, like
MoveLast.

(david)
"Reggie" <no**********@smittysinet.com> wrote in message
news:jv********************@comcast.com... After setting/changing the rowsource of the listbox/combo box try requerying it (i.e.. Me.mylistbox.Requery)

--
Reggie

www.smittysinet.com
----------
"Colleyville Alan" <ae***********@nospam.comcast.net> wrote in message
news:MXBoc.36511$z06.5767180@attbi_s01...
I have an app in which users are displayed a list of mutual fund from which
they can choose. There is a listbox embedded in a two-tabbed notebook
control. When the form is initally opened, the listbox loads info:

Private Sub Form_Open(Cancel As Integer)
TabControl.Value = 0
Tab_Label1.Caption = "Select Alternatives from the Select List"
FundAlternativesList.RowSource = "Load_Select_Alternatives_Form"
Call Highlight_Defaults
End Sub

The RowSource "Load_Select_Alternatives_Form" is a query that populates

the
listbox. Then I have this sub to change the values displayed depending

upon
which tab is selected:

Sub TabControl_Change()
If TabControl.Value = 0 Then
FundAlternativesList.RowSource = "Load_Select_Alternatives_Form"
FundAlternativesList.ColumnCount = 3
Tab_Label1.Caption = "Select Alternatives from the Select List"
Call Highlight_Defaults
Else
FundAlternativesList.RowSource = "Select_Gap_Funds"
FundAlternativesList.ColumnCount = 1
Tab_Label1.Caption = "Select Alternatives from the Revenue Sharing List"
End If
End Sub

This works fine too. But the whole point of the two tabs is to allow one to
choose funds from two different sources. If someone is on tab #1 and

clicks
a button to run a sub based on the funds that are selected, that sub

works fine. But if they then click on tab #2 immediately after that is finished running, the listbox is empty.

Reclicking on tab1 and then tab2 refreshes it properly, but that is not

the
way it is supposed to work. I have stepped through the code and watched

it
go right through the command that should refresh the data, but nothing
happens.

Can anyone tell me why this is occurring?


Nov 12 '05 #3
"david epsom dot com dot au" <david@epsomdotcomdotau> wrote in message
news:40**********************@news.syd.swiftdsl.co m.au...
After setting/changing the rowsource of the listbox/combo box try

requerying
it (i.e.. Me.mylistbox.Requery)


And if that doesn't work, refresh the count:

v = me.mylistbox.ListCount

Getting the count actually forces it to collect all of the rows, like
MoveLast.

(david)
"Reggie" <no**********@smittysinet.com> wrote in message
news:jv********************@comcast.com...
After setting/changing the rowsource of the listbox/combo box try

requerying
it (i.e.. Me.mylistbox.Requery)

--
Reggie

Thanks for the try, but neither solution worked. The listbox goes blank
when it hits the line:
FundAlternativesList.RowSource = "Select_Gap_Funds"

That is the same line of code that works when the box is first opened and
the user clicks on the tab. It also works after the box goes blank on that
command but then the first tab is clicked and the second tab is clicked once
again.

But while stepping through the code, I noticed that the block of code for
the first tab:
If TabControl.Value = 0 Then
FundAlternativesList.RowSource = "Load_Select_Alternatives_Form" FundAlternativesList.ColumnCount = 3
Tab_Label1.Caption = "Select Alternatives from the Select List" Call Highlight_Defaults
Also set the listbox blank (almost) and that my sub Highlight_Defaults
(which selects funds that were highlighted on a spreadsheet) was what reset
the listbox. When I said it almost sets the box blank - once column is
displayed even though there are three columns. In fact, the third column is
the only one showing. I see that my code sets the ColumnCount to 3, and
that is what I want - 3 columns to show. But not column #3 in the first
position! And after the call to Highlight_Defaults, the ColumnCount
actually is 3 with each field in the correct position.

Does this sound like a familiar problem? It sure seems that there is
something odd here!

BTW, I tried using each command separately and together both before and
after setting the rowsource property.

www.smittysinet.com
----------
"Colleyville Alan" <ae***********@nospam.comcast.net> wrote in message
news:MXBoc.36511$z06.5767180@attbi_s01...
I have an app in which users are displayed a list of mutual fund from

which
they can choose. There is a listbox embedded in a two-tabbed notebook
control. When the form is initally opened, the listbox loads info:

Private Sub Form_Open(Cancel As Integer)
TabControl.Value = 0
Tab_Label1.Caption = "Select Alternatives from the Select List"
FundAlternativesList.RowSource = "Load_Select_Alternatives_Form"
Call Highlight_Defaults
End Sub

The RowSource "Load_Select_Alternatives_Form" is a query that
populates
the
listbox. Then I have this sub to change the values displayed
depending upon
which tab is selected:

Sub TabControl_Change()
If TabControl.Value = 0 Then
FundAlternativesList.RowSource =
"Load_Select_Alternatives_Form" FundAlternativesList.ColumnCount = 3
Tab_Label1.Caption = "Select Alternatives from the Select List" Call Highlight_Defaults
Else
FundAlternativesList.RowSource = "Select_Gap_Funds"
FundAlternativesList.ColumnCount = 1
Tab_Label1.Caption = "Select Alternatives from the Revenue

Sharing List"
End If
End Sub

This works fine too. But the whole point of the two tabs is to allow one
to
choose funds from two different sources. If someone is on tab #1 and

clicks
a button to run a sub based on the funds that are selected, that sub

works fine. But if they then click on tab #2 immediately after that is finished running, the listbox is empty.

Reclicking on tab1 and then tab2 refreshes it properly, but that is

not the
way it is supposed to work. I have stepped through the code and
watched it
go right through the command that should refresh the data, but nothing
happens.

Can anyone tell me why this is occurring?



Nov 12 '05 #4
"Colleyville Alan" <ae***********@nospam.comcast.net> wrote in message
news:OTJoc.39350$536.7125415@attbi_s03...
Also set the listbox blank (almost) and that my sub Highlight_Defaults
(which selects funds that were highlighted on a spreadsheet) was what reset the listbox. When I said it almost sets the box blank - once column is
displayed even though there are three columns. In fact, the third column is the only one showing. I see that my code sets the ColumnCount to 3, and
that is what I want - 3 columns to show. But not column #3 in the first
position! And after the call to Highlight_Defaults, the ColumnCount
actually is 3 with each field in the correct position.

Does this sound like a familiar problem? It sure seems that there is
something odd here!

BTW, I tried using each command separately and together both before and
after setting the rowsource property.


Never mind, I found the problem. It seems that having the line that sets
the ColumnCount:
FundAlternativesList.ColumnCount = 1
after the code that sets the RowSource property is the problem. Putting it
before that code executes fixes it.

So this does not work:
Else
FundAlternativesList.RowSource = "Select_Gap_Funds"
FundAlternativesList.ColumnCount = 1
Tab_Label1.Caption = "Select Alternatives ..."
End If

But this does:
Else
FundAlternativesList.ColumnCount = 1
FundAlternativesList.RowSource = "Select_Gap_Funds"
Tab_Label1.Caption = "Select Alternatives ..."
End If

Does anyone know why that is the case? I'm happy to have a solution, but
I'm also trying to understand the logic.
Nov 12 '05 #5
Glad you fixed it. Didn't notice your sequence at first. I believe once
you start changing the properties (column count) it resets the control. If
you think about it, it makes sense. Lets assume your other piece of code
which changes it from 1 column to 3. The first thing you "were" doing was
trying to cram 3 columns of data into a 1 column listbox, then you were
adding the other 2 columns. Not much of an answer, but just trying to
figure it out and this "seems" to be a logical answer.

--
Reggie

www.smittysinet.com
----------
"Colleyville Alan" <ae***********@nospam.comcast.net> wrote in message
news:H0Koc.243$Dz.58013@attbi_s52...
"Colleyville Alan" <ae***********@nospam.comcast.net> wrote in message
news:OTJoc.39350$536.7125415@attbi_s03...
Also set the listbox blank (almost) and that my sub Highlight_Defaults
(which selects funds that were highlighted on a spreadsheet) was what reset
the listbox. When I said it almost sets the box blank - once column is
displayed even though there are three columns. In fact, the third

column is
the only one showing. I see that my code sets the ColumnCount to 3, and
that is what I want - 3 columns to show. But not column #3 in the first
position! And after the call to Highlight_Defaults, the ColumnCount
actually is 3 with each field in the correct position.

Does this sound like a familiar problem? It sure seems that there is
something odd here!

BTW, I tried using each command separately and together both before and
after setting the rowsource property.
Never mind, I found the problem. It seems that having the line that sets
the ColumnCount:
FundAlternativesList.ColumnCount = 1
after the code that sets the RowSource property is the problem. Putting

it before that code executes fixes it.

So this does not work:
Else
FundAlternativesList.RowSource = "Select_Gap_Funds"
FundAlternativesList.ColumnCount = 1
Tab_Label1.Caption = "Select Alternatives ..."
End If

But this does:
Else
FundAlternativesList.ColumnCount = 1
FundAlternativesList.RowSource = "Select_Gap_Funds"
Tab_Label1.Caption = "Select Alternatives ..."
End If

Does anyone know why that is the case? I'm happy to have a solution, but
I'm also trying to understand the logic.

Nov 12 '05 #6
"Reggie" <no**********@smittysinet.com> wrote in message
news:Q5********************@comcast.com...
Glad you fixed it. Didn't notice your sequence at first. I believe once
you start changing the properties (column count) it resets the control. If you think about it, it makes sense. Lets assume your other piece of code
which changes it from 1 column to 3. The first thing you "were" doing was
trying to cram 3 columns of data into a 1 column listbox, then you were
adding the other 2 columns. Not much of an answer, but just trying to
figure it out and this "seems" to be a logical answer.
Well I thought it worked - sometimes it does and sometimes it does not.
I've stepped through the code and the correct lines are being executed, the
variables are being set. But they simply do not seem to affect anything. I
have to re-write this section anyway, so I may not have this problem when I
am done. But for now, it seems intermittent, though there is probably an
underlying pattern that I am missing.

CA

--
Reggie

www.smittysinet.com
----------
"Colleyville Alan" <ae***********@nospam.comcast.net> wrote in message
news:H0Koc.243$Dz.58013@attbi_s52...
"Colleyville Alan" <ae***********@nospam.comcast.net> wrote in message
news:OTJoc.39350$536.7125415@attbi_s03...
Also set the listbox blank (almost) and that my sub Highlight_Defaults
(which selects funds that were highlighted on a spreadsheet) was what

reset
the listbox. When I said it almost sets the box blank - once column is displayed even though there are three columns. In fact, the third column
is
the only one showing. I see that my code sets the ColumnCount to 3, and that is what I want - 3 columns to show. But not column #3 in the first position! And after the call to Highlight_Defaults, the ColumnCount
actually is 3 with each field in the correct position.

Does this sound like a familiar problem? It sure seems that there is
something odd here!

BTW, I tried using each command separately and together both before and after setting the rowsource property.


Never mind, I found the problem. It seems that having the line that

sets the ColumnCount:
FundAlternativesList.ColumnCount = 1
after the code that sets the RowSource property is the problem. Putting

it
before that code executes fixes it.

So this does not work:
Else
FundAlternativesList.RowSource = "Select_Gap_Funds"
FundAlternativesList.ColumnCount = 1
Tab_Label1.Caption = "Select Alternatives ..."
End If

But this does:
Else
FundAlternativesList.ColumnCount = 1
FundAlternativesList.RowSource = "Select_Gap_Funds"
Tab_Label1.Caption = "Select Alternatives ..."
End If

Does anyone know why that is the case? I'm happy to have a solution, but I'm also trying to understand the logic.


Nov 12 '05 #7
> Well I thought it worked - sometimes it does and sometimes it does not.

Also watch for errors caused by binding to an empty recordset.
As you know, the detail section of a form is not rendered if
the form is bound to an empty recordset: sometimes there are
problems associated with this.

(david)
"Colleyville Alan" <ae***********@nospam.comcast.net> wrote in message
news:Zt3pc.47628$z06.6823157@attbi_s01...
"Reggie" <no**********@smittysinet.com> wrote in message
news:Q5********************@comcast.com...
Glad you fixed it. Didn't notice your sequence at first. I believe once
you start changing the properties (column count) it resets the control. If
you think about it, it makes sense. Lets assume your other piece of code
which changes it from 1 column to 3. The first thing you "were" doing was trying to cram 3 columns of data into a 1 column listbox, then you were
adding the other 2 columns. Not much of an answer, but just trying to
figure it out and this "seems" to be a logical answer.


Well I thought it worked - sometimes it does and sometimes it does not.
I've stepped through the code and the correct lines are being executed,

the variables are being set. But they simply do not seem to affect anything. I have to re-write this section anyway, so I may not have this problem when I am done. But for now, it seems intermittent, though there is probably an
underlying pattern that I am missing.

CA

--
Reggie

www.smittysinet.com
----------
"Colleyville Alan" <ae***********@nospam.comcast.net> wrote in message
news:H0Koc.243$Dz.58013@attbi_s52...
"Colleyville Alan" <ae***********@nospam.comcast.net> wrote in message
news:OTJoc.39350$536.7125415@attbi_s03...
> Also set the listbox blank (almost) and that my sub Highlight_Defaults > (which selects funds that were highlighted on a spreadsheet) was what reset
> the listbox. When I said it almost sets the box blank - once column is > displayed even though there are three columns. In fact, the third

column
is
> the only one showing. I see that my code sets the ColumnCount to 3, and > that is what I want - 3 columns to show. But not column #3 in the first > position! And after the call to Highlight_Defaults, the ColumnCount
> actually is 3 with each field in the correct position.
>
> Does this sound like a familiar problem? It sure seems that there is > something odd here!
>
> BTW, I tried using each command separately and together both before and > after setting the rowsource property.

Never mind, I found the problem. It seems that having the line that sets the ColumnCount:
FundAlternativesList.ColumnCount = 1
after the code that sets the RowSource property is the problem.
Putting it
before that code executes fixes it.

So this does not work:
Else
FundAlternativesList.RowSource = "Select_Gap_Funds"
FundAlternativesList.ColumnCount = 1
Tab_Label1.Caption = "Select Alternatives ..."
End If

But this does:
Else
FundAlternativesList.ColumnCount = 1
FundAlternativesList.RowSource = "Select_Gap_Funds"
Tab_Label1.Caption = "Select Alternatives ..."
End If

Does anyone know why that is the case? I'm happy to have a solution,

but I'm also trying to understand the logic.



Nov 12 '05 #8

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

17 posts views Thread by amber | last post: by
5 posts views Thread by Bill | last post: by
6 posts views Thread by Janaka | last post: by
reply views Thread by amber | last post: by
4 posts views Thread by amber | last post: by
15 posts views Thread by Doogie | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by Marin | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.