Multiple listboxes and one text box

  • Thread starter Thread starter AccessFreak via AccessMonster.com
  • Start date Start date
A

AccessFreak via AccessMonster.com

Ok... here's the deal. I have 6 listboxes on one from. They are all piled
on top of one another and a case select statement controls which one is
viewable. When I click on an entry in the listbox, I have a textbox linked
so it contains the record's primary key's number. When another form is
opened it's record selection is based on the primary key number on the main
form? Have a lost anyone yet?

Here's what I need. I need to understand how to code the textbox so that no
matter which listbox I am looking at, the textbox will always display the
primary key number. Here what I am currently using:

Textbox: =[List235] (in the control source)

I need that single textbox to read from List247, List248, List249, List249,
List250, and List251.

Any help would be appreciated.
 
Warning: Seeing the Access generated numbers that you are
using for your ListBoxes ( in the 200's! ) you may have some
serious design rethinking to do. Have you really put 200+
listboxes (or even controls) on that form? Stacking the 6
listboxes and toggling visibility is another indicator of
potential design weaknesses.

Irregardless, if you need the textbox to be changed no
matter which listbox is visible I suggest 'pushing' the data
to the textbox from the listbox instead of 'pulling' it from
the textbox.

In the AfterUpdate event of your various listboxes put the
following with your proper textbox name and the respective
name of that listbox...

Me!YourTextBoxName = Me!List235

By the way, you could probably bypass the textbox by opening
the form directly from the AfterUpdate events of the
listboxes by using the WHERE clause of the OpenForm method
and avoid having the form's query have to read the form
textbox.


Gary Miller
Sisters, OR
 
Hey AccessFreak,

First, I guess I would ask you a question. Rather than having 6 listboxes
why don't you have 1 and change the Rowsource of the listbox according the
the choice made? If there are different column counts; column widths and etc,
then you could always change them using code also.

Second. Why use the textbox to hold the primary key, when it's already
stored in the listbox? You could use your code to open the form using the
primary key from the listbox On Click event, instead of the textbox.

As far as answering your question. In each of the listboxes AfterUpdate
event you could put.

Me.TextBoxName = Me.ListboxName
'This should put the primary key in the textbox as long as it's the first
column, otherwise you will need to add
..Column(1) if it's the second column and etc.

HTH,
Shane


Ok... here's the deal. I have 6 listboxes on one from. They are all piled
on top of one another and a case select statement controls which one is
viewable. When I click on an entry in the listbox, I have a textbox linked
so it contains the record's primary key's number. When another form is
opened it's record selection is based on the primary key number on the main
form? Have a lost anyone yet?

Here's what I need. I need to understand how to code the textbox so that no
matter which listbox I am looking at, the textbox will always display the
primary key number. Here what I am currently using:

Textbox: =[List235] (in the control source)

I need that single textbox to read from List247, List248, List249, List249,
List250, and List251.

Any help would be appreciated.
 
I concur - have source data with a field to designate what you now what for
the different list boxes --
ID - autonumber
Group - number - integer
Label - text

1 1 Apple
2 1 Pear
3 1 Banana
4 2 Pecan
5 2 Walnut
6 2 Peanut
7 3 Pinto
8 3 Blackeye
9 3 Navy

Shane S via AccessMonster.com said:
Hey AccessFreak,

First, I guess I would ask you a question. Rather than having 6 listboxes
why don't you have 1 and change the Rowsource of the listbox according the
the choice made? If there are different column counts; column widths and etc,
then you could always change them using code also.

Second. Why use the textbox to hold the primary key, when it's already
stored in the listbox? You could use your code to open the form using the
primary key from the listbox On Click event, instead of the textbox.

As far as answering your question. In each of the listboxes AfterUpdate
event you could put.

Me.TextBoxName = Me.ListboxName
'This should put the primary key in the textbox as long as it's the first
column, otherwise you will need to add
..Column(1) if it's the second column and etc.

HTH,
Shane


Ok... here's the deal. I have 6 listboxes on one from. They are all piled
on top of one another and a case select statement controls which one is
viewable. When I click on an entry in the listbox, I have a textbox linked
so it contains the record's primary key's number. When another form is
opened it's record selection is based on the primary key number on the main
form? Have a lost anyone yet?

Here's what I need. I need to understand how to code the textbox so that no
matter which listbox I am looking at, the textbox will always display the
primary key number. Here what I am currently using:

Textbox: =[List235] (in the control source)

I need that single textbox to read from List247, List248, List249, List249,
List250, and List251.

Any help would be appreciated.
 
The large numbers on the list boxes are from adding, deleting, adding,
deleting, and so on. This is a prototype database so there's going to be
large numbers.

Anyway, here's the whole layout:

ID
Name
Department
Date
DueDate
Description
AssignedTo
Status
EnteredBy

I want to use a listbox, but I need to allow the user to enter in keywords
and query across the Name, Department, Due Date, Description, and Assigned To
fields.

This is why I resorted to a listbox for to query each field.

I am all ears if I can use one listbox and allow the user to use keywords to
query across all the fields listed above.

Hope this helps. Yell, if you need more information.
 
Once again, I remove my hat and bow my head to the Access Gods on these
forums.

I opted to create actual queries and use the "changing of the rowsource"
suggestion in my case select statements. My user is able to put in the
search criteria and I am able to jump from query to query and still use the
same listbox.

Once again. Thank you. Problem solved.
 
Hey AccessFreak,

Your welcome. Glad to have had a part in helping.

Shane
 
Back
Top