472,811 Members | 1,963 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,811 software developers and data experts.

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 1959
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
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
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
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
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
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
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
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
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
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
by: erikbower65 | last post by:
Using CodiumAI's pr-agent is simple and powerful. Follow these steps: 1. Install CodiumAI CLI: Ensure Node.js is installed, then run 'npm install -g codiumai' in the terminal. 2. Connect to...
0
by: erikbower65 | last post by:
Here's a concise step-by-step guide for manually installing IntelliJ IDEA: 1. Download: Visit the official JetBrains website and download the IntelliJ IDEA Community or Ultimate edition based on...
0
by: kcodez | last post by:
As a H5 game development enthusiast, I recently wrote a very interesting little game - Toy Claw ((http://claw.kjeek.com/))。Here I will summarize and share the development experience here, and hope it...
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Sept 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: Taofi | last post by:
I try to insert a new record but the error message says the number of query names and destination fields are not the same This are my field names ID, Budgeted, Actual, Status and Differences ...
14
DJRhino1175
by: DJRhino1175 | last post by:
When I run this code I get an error, its Run-time error# 424 Object required...This is my first attempt at doing something like this. I test the entire code and it worked until I added this - If...
0
by: Rina0 | last post by:
I am looking for a Python code to find the longest common subsequence of two strings. I found this blog post that describes the length of longest common subsequence problem and provides a solution in...
5
by: DJRhino | last post by:
Private Sub CboDrawingID_BeforeUpdate(Cancel As Integer) If = 310029923 Or 310030138 Or 310030152 Or 310030346 Or 310030348 Or _ 310030356 Or 310030359 Or 310030362 Or...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{

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.