Displaying correct data in textbox/control (depending on values selected in a combo box)

G

Guest

OK, here's the basic structure of my database

Station Tabl
Each station can have multiple parts (Station prim key unique

Part Tabl
Part # prim key unique.

Location Tabl
ach location can have multiple parts (Location prim key unique

I then have 2 joining tables and did one to many relationships to setup a many to many relationship as described above as per the help in access. This way for example, Station A1 could have many different parts as well as a certain number of those parts

The data itself works fine

The forms work fine , ie. ON my Station:browse parts form, I select the station (primary key) which automatically refreshes the list of corresponding parts and part #'s (which are in a subform). The station combo box is unbound

My only problem is, if I want to also display the corresponing station description (a field on the station table), I can't figure out a way of doing this. I know I want it to look a the value currently in the station combo box, and display the corresponding station description (Perhaps just in a textbox?

ANy ideas?

Thanks,

Matt Lawson
 
G

Gerald Stanley

Try something along the following lines
1- Ensure that RowSource SQL for your comboBox selects the
station name as well as the station primary key. e.g.
SELECT station, stationName FROM Station
2- Ensure that the number of columns property for the combo
box = 2
2- Create a text box on the form.
3- Place code in the AfterUpdate event handler of the combo
Box as follows

{yourtextboxname}.Value = {yourcomboboxname}.Column(1)

You could achieve a simialr effect without the need for a text
box as follows
- Change the RowSource SQL to something like
SELECT stationName, station FROM Station
- Change the Bound Column to 2
- Ensure that the Number of Columns = 2
What you should then see is the Station Name appear in the
text box part of the comboBox and the subForm should still
show the correct parts

Hope That Helps
Gerald Stanley MCSD
-----Original Message-----
OK, here's the basic structure of my database:

Station Table
Each station can have multiple parts (Station prim key unique)

Part Table
Part # prim key unique.

Location Table
ach location can have multiple parts (Location prim key unique)

I then have 2 joining tables and did one to many
relationships to setup a many to many relationship as
described above as per the help in access. This way for
example, Station A1 could have many different parts as well
as a certain number of those parts.
The data itself works fine.

The forms work fine , ie. ON my Station:browse parts
form, I select the station (primary key) which automatically
refreshes the list of corresponding parts and part #'s (which
are in a subform). The station combo box is unbound.
My only problem is, if I want to also display the
corresponing station description (a field on the station table),
I can't figure out a way of doing this. I know I want it to look
a the value currently in the station combo box, and display the
corresponding station description (Perhaps just in a textbox?)
 
G

Guest

Hrmm, I tried the code you mentioned with Bound Column = 2 and the code for the textbox

However, after that , the subform did not work correctly (right parts did not show up)

Just for hell of it I also

verified with Bound Column =1 and the code referring to column(0), and it did update the textbox when I changed the stationname combo box

ANy ideas? It seems to me changing Bound Column =2 made my subform not show the right parts anymore

Any more help would be appreciated, thanks a bunch in advance

Matt LAwson
 

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

Top