| Author |
Message |
Laurie Comerford
Guest
|
Posted:
Sat Apr 02, 2005 10:03 am Post subject:
Populating list boxes during form initialisation |
|
|
Hi,
I'm reading data from a data base and using the data to populate two list
boxes using the form Initialisation event.
My ambition is to populate one list box first, set it's list index to 0 and
then read the value from there as a selection parameter for populating the
second list box.
However, as I step through the code I find that the first list box has no
value during the form initialisation.
It makes no difference if I move the code to the Form Activate event during
the initial opening of the form.
Is this the normal way forms are activated - ie that list boxes have no
readable data till the form actually appears to the user?
I have used a work around by sending the first value in the first box to a
temporary variable, but that seems inelegant.
--
Laurie Comerford
CADApps
www.cadapps.com.au
|
|
| Back to top |
|
 |
fantum
Guest
|
Posted:
Sat Apr 02, 2005 4:30 pm Post subject:
Re: Populating list boxes during form initialisation |
|
|
It's hard to say what the problem might be without a look at the code. Does this do something like what you want?
Private Sub ListBox1_Click()
Dim s As String
s = ListBox1.List(ListBox1.ListIndex)
With ListBox2
.Clear
.AddItem s & "_1"
.AddItem s & "_2"
.AddItem s & "_3"
.AddItem s & "_4"
End With
End Sub
Private Sub UserForm_Initialize()
With ListBox1
.AddItem "1"
.AddItem "2"
.AddItem "3"
.ListIndex = 0
End With
End Sub |
|
| Back to top |
|
 |
John Goodfellow
Guest
|
Posted:
Sun Apr 03, 2005 12:21 am Post subject:
Re: Populating list boxes during form initialisation |
|
|
If you are loading the first listbox from a recordset in its row order, then
you should have the value for the second listbox's (recordset's) criteria in
the first row of the first recordset. I'm guessing, maybe misunderstanding.
--
John Goodfellow
irtfnm
use john at goodfellowassoc dot com
"Laurie Comerford" <laurie@DeleteThiscadapps.com.au> wrote in message
news:424e3e6a_2@newsprd01...
| Quote: | Hi,
I'm reading data from a data base and using the data to populate two list
boxes using the form Initialisation event.
My ambition is to populate one list box first, set it's list index to 0
and
then read the value from there as a selection parameter for populating the
second list box.
However, as I step through the code I find that the first list box has no
value during the form initialisation.
It makes no difference if I move the code to the Form Activate event
during
the initial opening of the form.
Is this the normal way forms are activated - ie that list boxes have no
readable data till the form actually appears to the user?
I have used a work around by sending the first value in the first box to a
temporary variable, but that seems inelegant.
--
Laurie Comerford
CADApps
www.cadapps.com.au
|
|
|
| Back to top |
|
 |
|
|
|
|