please help!

A

aheath15

have been trying to figure out this frusterating detail for the last week,
and still have not gotten it to work correctly:

I have a form, connected to a table, which displays a list of products and
corresponding details. The purpost of this form is that it will be used by a
user creating an order. I.E. there is an option box (check/uncheck) which
allows the user to select the product if it is part of the order. I later
run a query to compile all 'selections' and etc-.

This is my problem:
I need to write some kind of code that will automatically select one product
if another is selected. In other words, I know I need some kind of If
statement saying "If product A's option = true, then Product C's option =
true". I have NO idea how to do this. I know that I will have to insert
something in the 'after update' property of the check box, but i do not know
what. My main source of frusteration is stemming from my inability to
reference what I need to, because it is just one record that I want to be
true, not the entire option field for the entire list of products.

So, for clarification purposes, say the Primary Key ID for product A is 1,
and 2 for Product B. In my head I need some statement saying
If(option.1=true) Then (option.2=true) but so far this has not been working.
How do I reference specific records of specific tables? I have tried using
the expression builder and navigating through the files to get here but that
doesn't work either.

If there's any examples that could be used as an answer (with the necessary
code commands and how i reference the information needed) that would be great!
Any help would be HUGELY appreciated.
 
T

Tim Ferguson

I need to write some kind of code that will automatically select one
product if another is selected. In other words, I know I need some
kind of If statement saying "If product A's option = true, then
Product C's option = true". I have NO idea how to do this. I know
that I will have to insert something in the 'after update' property of
the check box, but i do not know what.

One way to address this would be with a new table called Dependencies:

CREATE TABLE Dependencies
( PrimaryProduct Long Integer not null
foreign key PrimProd references Products(ProductID),

IsNeeded Long Integer not null
foreign key IsNeed references Products(ProductID)

constraint PK Primary Key (PrimaryProduct, IsNeeded)
)


and this would contain one record for every "rule" e.g.

A, W
B, W
B, X

means "A needs W" and "B needs W and X", etc. It's a fairly easy job then
to fix up a query to identify the required bits:

SELECT DISTINCT IsNeeded
FROM Dependencies
WHERE PrimaryProduct IN
( SELECT ProductID
FROM MyOrderTable
WHERE SomeCriterion=TRUE
)

The inner subquery gets the bits the user identified, the outer one
returns all the new required ones.

If you have nested requirements (e.g. add a row (W, Y) to the above) and
you have a more sophisticated problem... start googling for something
like "SQL SubAssemblies".

Hope that helps


Tim F
 
G

George Walsh

How about this concept?

If your individual product elements are all included as records located in
one table or query, and you have a key field such as ProductID, you can
identify the appropriate product records by setting a filter that is
evaluated based on the output of checked products a user indicates on your
order form.

Perhaps you could have a SELECT CASE code structure that evaluates which
specific product records have been selected on your order form upon the
event of the user clicking on a "Place Order Now" command button.

The executed code would also evaluate which products to include in the order
by token of the fact that they are required merely because of the selection
of some other product. These dependent products can be defined as ordering
rules which are built-in to the SELECT CASE code structure, and the
resulting output would be evaluated as an "order string" that specifies
exactly which product IDs are required to fulfill the entire specified
order,

Such an order string can then be passed to become a filter on the Product
table or query records, thus restricting the display of products to include
only the specific products - either actually checked or required by other
products that have been checked.
 

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


Top