473,503 Members | 2,289 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 1997
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

17
3088
by: amber | last post by:
Hello. Can someone tell me what I may be doing wrong here? I'm using the code (lboxRP is a listbox): Dim newRPindex As Integer newRPindex = Me.lboxRP.FindString(RP)...
5
3499
by: Bill | last post by:
I have have two list boxes. One is a listing of all possible variables. We'll call this listbox A. The other is a listing of all the selected variables. We'll call this listbox B. If a person...
2
3155
by: Joey | last post by:
Hi There, I am trying to get the selected value of a listbox when I click a button, everything works ok and I can bind the list and when I have a basic page and click a button to invoke a sub it...
6
5177
by: Janaka | last post by:
Help! I have two ListBox controls on my web form. The first one gets populated on entry with values from the DB. I then use JavaScript to copy options from this ListBox to my second one. (I...
0
1214
by: amber | last post by:
Hello, I'm having problems with a listbox... I have a listbox that is populated when a user presses a button (retrieve). There is a textbox on the form, and if the textbox is left blank, and...
4
322
by: amber | last post by:
Hello I'm not sure if I should give up trying to find an answer here...or just keep posting my problem.. I'm having problems with a listbox.. I have a listbox that is populated when a user...
2
2903
by: teo | last post by:
I have a Listbox, if I set EnableViewStarte = False the AutopostaBack fired by SelectedIndexChanged doesn't work. The 'SelectedIndexChanged' event should call
18
4582
by: Zytan | last post by:
I want the same function to be run whether you press Enter or double click the listbox. It seems really verbose to write both handlers to both events everytime, even if they both call the same...
15
2339
by: Doogie | last post by:
I have a .net app that a user currently enters a number in a text box, hits a button and a data call is executed. She wants the ability to enter in multiple numbers (up to 100). So to make...
0
7207
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7291
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
7357
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
5598
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5023
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4690
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3180
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
1522
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
748
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.