Best Way to offer multiple sizes

  • Thread starter Thread starter Rich Schoenfeld
  • Start date Start date
R

Rich Schoenfeld

I can't seem to figure out the best way to offer products with different
sizes in a subform. I tried to create a datasheet view that uses a combo
box for the different products to purchase and a combo box for sizes.

Once they have selected a product, I try to change the dropdown recordsource
of the product sizes to limit it to the particular product sizes. It seems
to work, but then I noticed if I want to purchase two items, the
recordsource changes for both products that were ordered.

Any ideas?

thanks,
Rich
 
Yes, if you want to use continuous forms, that is a problem. You cannot
requery a list or combo box and have the data limited. You might consider
using a popup form to choose the size and have the data returned to a
textbox in the record.
--
Arvin Meyer, MCP, MVP
Microsoft Access
Free Access downloads
http://www.datastrat.com
http://www.mvps.org/access
 
If your Size field is unbound (not tied to a field in the table that the
form gets its records from), then the value will apply to all records, and
you will have no record later of what value was used. The solution will be
to add a field to your table for the size, and set the Control Source of
this text box to this new field.

The specifics will depend on what tables you have. Since you say you are
restricting the size to those that apply to the product, you will need these
3 tables:

Product table (one record for each product):
ProductID primary key
ProductName text
...

Size table (one record for each size):
SizeID primary key. (Text?)
SortOrder how to sort this entry.

ProductSize table (one record for every combination of product + size):
ProductID Number relates to Product.ProductID
SizeID Text relates to Size.SizeID
(Combination of both fields as primary key.)

I have suggested a Text field as primary key of the Size table, since that
copes with all kinds of size, e.g. S, M, L. But those sources don't sort
correctly, e.g. L(arge) sorts before M(edium), so you need the sort order
field as well, so you can sort the drop-down list correctly. Now you will
have tables that use these 3. Typically it's a pair of tables like the Order
and Order Details in the Northwind sample database, because one order can
have many line items. So, you will have:

Order table (one record for each order received):
OrderID primary key (autonumber)
OrderDate date/time (when ordered)
ClientID relates to Client.ClientID (whose order)

OrderDetail table (one record for each line of an order):
OrderDetailID AutoNumber
OrderID Number. Relates to Order.OrderID
ProductID Number. Relates to ProductSize.ProductID
SizeID Text Relates to ProductSize.SizeID
Quantity Number
UnitPriceEx Currency (price each without tax.)
TaxRate Number (tax to add for this row.)

Since the OrderDetail table ties the ProductID and SizeID back to the
ProductSize table, and you will create a relationship with referential
integrity enforced (Tools | Relationships), it is now impossible to enter a
record for a bad combination of product and size.
 
Thanks for the reply...

I have the tables set up pretty much as you describe. The problem is that I
can't easily display only those sizes which pertain to a particular product.
I want to be able to pick a product, and then the sizes can be chosen. It
is easy to do if I only allow one product, but if I allow a user to select a
second product and size, the solutions are awkward and inefficient.

-Rich
 
I am thinking of doing it that way, but it just seems inefficient, and not
very clean.

Thanks
 
If the question is how to restrict the SizeID combo so it shows only those
that apply for the product in the ProductID combo, you will need to set the
RowSource of the combo in its Enter event

Details in:
Limit content of combo/list boxes
at:
http://www.mvps.org/access/forms/frm0028.htm

There is a side-issue here. If you use a continuous form and restrict the
RowSource so that the combo does not contain the values needed in other
rows, the combo goes blank on those rows if the Bound Column is zero-width.
You can avoid that issue if you do not hide the bound column. The structure
suggested previously (with the Text-based SizeID field) solves that problem.
 

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

Back
Top