Ray:
I think the pertinent point is:
"If the Sub Form is based on the Customers table, all that will be shown is
the Supplier Number that is held in the Customer Table"
By making the control in the subform bound to the field containing the
Supplier Number a combo box, and hiding the bound column, you can show the
supplier name from another column. To do this set up the combo box as
follows:
RowSource: SELECT [Supplier Number], [Supplier Name] FROM [Suppliers]
ORDER BY [Supplier Name];
BoundColumn: 1
ColumnCount: 2
ColumnWidths: 0cm;8cm
If your units of measurement are imperial rather than metric Access will
automatically convert the last one. The important thing is that the first
dimension is zero to hide the first column and that the second is at least as
wide as the combo box.
This is the standard way of showing meaningful data form a column of a
referenced table where the keys are arbitrary values, usually numeric.
Although the value of the control is the number, what you see is the
corresponding text value from the Supplier Name column in the Suppliers table.
As it's a combo box, selecting another supplier from the drop down list would
change the value of the bound Supplier Number column in the Customers table
of course if the subform is updatable. This can be prevented by setting the
combo box's Locked property to True (Yes) and its Enabled property to False
(No) as I described earlier.
You can extend this if necessary to show other data from the Suppliers table
in the subform by including the relevant columns in the combo box's RowSource
and referencing the columns in an unbound text box in the subform; say for
instance you also wanted to show data from a column Supplier Address you'd
set up the combo box like this:
RowSource: SELECT [Supplier Number], [Supplier Address], [Supplier Name]
FROM [Suppliers] ORDER BY [Supplier Name];
BoundColumn: 1
ColumnCount: 3
ColumnWidths: 0cm;0cm;8cm
Then add an unbound text box to the subform, with a ControlSource property of:
=cboSupplier.Column(1)
where cboSupplier is the name of the combo box. The column property is zero-
based, so Column(1) is the second column, Supplier Address.
Ken Sheridan
Stafford, England
Post by Ray CHi Ken
Thank you so much for coming back to me. I have tried and tried to
understand and implement both your alternatives but neither to any avail.
First of all, i am an absolute beginer with Accesss and I am begining to
think that I have some fundamental misunderstandings about how Access works.
I may not have explained the way I have things set up too well to you. I
have a "frm_Main" and that form has 4 unbound "Find Combo Boxes" that are
used to search the various tables. it also has 2 "unbound" Sub Form controls
that are used to display the information that is requested by the user and
held in diffrent "Sub Forms that are based on the table in which the
information is held.
e.g. if the User wants to view Supplier names and address information that
is held in the "suppliers" table, they select Suppliers from the appropriate
combo box in The "Frm_Main" and this populates the appropriate "Find"
Combo's with options available to that particular request (supplier name,
Supplier ID, Contract No etc). The selection of the correct record from one
of these find boxes will search the Table and set the Record with a Bookmark.
The program then sets the Source Object of the Sub Form Control as the
appropriate Sub Form, make it visible and that is job done.
All that works OK other than the situation I was trying to resolve when I
originaly made the enquiry. One of the Tables (the Customers Table) has 3
different fields that hold the Supplier Primary Key number from the Suppliers
Table as an indication of the supplier that provides that particular service.
this could be any combination of one supplier that supplies all 3 services;
through to the different suppliers that supply the 3 different services. If
the Sub Form is based on the Customers table, all that will be shown is the
Supplier Number that is held in the Customer Table. I wanted to use that
number to Look up the supplier name. (e.g. I wanted Supplier number 254 held
in the appropriate Field of the Customers Table to Look up the Number
(primary key) in the "Suppliers" Table and return the name of the supplier
associated with that record. I did this with a List Box where the Row Source
was set with the statement in the message below.
That did not work as the Lisy Box always remained Blank. I changed the line
to simply reference the Form Property with Form!SW_Opp but that did not work.
I changed the Sub Form to be based on a Query as you suggest but that does
not work as there seems to be nothing to link the seloection of the Customer
that is selected with its information shown in the first Sub form Control
(based on the Customer Table) with the second Sub form that is based on the
query.
Also, by using the query I can generate the Text Box that controls the Name
of the Supplier for one of the 3 (Potentially) different suppliers held in
the Customers Table but I acn not generate a Text Box that will display the
names of the other two. Surely this information has to be displayed by a
Lookup?
Sorry this is so long. but any help will be usefull.
Thanks Ray C
Post by KenSheridan via AccessMonster.comSimply base the subform on a query which joins the two tables and include the
SupplierName in the query's columns. You can then include a text box control
[quoted text clipped - 37 lines]
--
Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/Forums.aspx/access-gettingstarted/201005/1