Combo box selection generates a LIST of values to a text box

L

LLao

I've looked all over access for help on this but could not find the perfect
fit. I’ve read everything I could find on cascading but that’s not exactly
what I want. Here goes.
I have a combo box that contains test names, and based on the test name
selected, I would like it to output (into a test box preferably which can
shrink or grow to fit the list size) a list of the data pertaining to that
specific test. The same data name can be used for different tests. Lastly, I
would like the values for this list to be stored on the form.

For example, my table, tblOperation, will have two fields: TestName, Data.
The first test, let’s call it Test1 for simplicity, contains data: Temp1,
Temp2, Temp3.
Test2, will contain data: Temp1, Temp2, Jitter1, Jitter2, Jitter3
Test3, will contain data: Jitter1, Sensor1

This is the table I have so far:
TestName Data
Test1 Temp1
Test1 Temp2
Test1 Temp3
Test2 Temp1
Test2 Temp2
Test2 Jitter1
Test2 Jitter2
Test2 Jitter3
Test3 Jitter1
Test3 Sensor1

I know how to get my combo box to display “Test1, Test2, Test3â€, by using
the following code in the RowSource:
SELECT DISTINCT tblOperation.TestName FROM tblOperation;

But I am having trouble with the second part on how to select “Test1†from
the combo box and have that automatically generate a text box showing the
data values “Temp1, Temp2, Temp3â€, or selecting "Test2" and outputting
"Temp1, Temp2, Jitter1, Jitter2, Jitter3" etc.
I have the code below but I think it only works on combo boxes, and I need
the box outputting the data to be a text box (or some box type that will
allow for data of varying size, ie CanGrow or CanShrink to fit it) that
stores the data values.

SELECT DISTINCTROW tblOperation.data FROM tblOperation WHERE
(((tblOperation.TestName) Like forms!frmSimple!combo0));

Please help, this has been driving me nuts for days. Thanks!
 
W

Wayne Morgan

As long as the Data is short, as in your examples, you could use the query
as the Row Source of a listbox. What you've read about cascading would then
apply. This listbox doesn't have a grow/shrink option. Instead, it will give
you a vertical scroll bar if you exceed the visible height of the listbox.
You could adjust the height property of the listbox though by multiplying
the height of each row by the number or rows. To get this value, create a 1"
high listbox and fill it, count the number of rows and divide to get the
average height of a row. You may need to adjust this slightly after a few
tests, but it ought to be close.

Example:
For a 1" high listbox that displays 7 full rows (if it only displays 6.5,
use 6.5 instead of 7)

Me.List2.Height = (1 / 7) * Me.List2.ListCount * 1440

The 1440 is because the value is actually in Twips (1440 Twips = 1"). You
may also need to set the Can Grow/Can Shrink properties of the form's
section that the control is in.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads

Combo box 0
Email Mail Merge via linked Excel sheet 0
looping to through rows 1
Combo Boxes 4
Check boxes - secondary data source 2
list or combo box 0
Combo Box Filter 2
Address selection on combo box help 2

Top