help!

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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.

Any help would be HUGELY appreciated.
 
The central point of your problem is how to know that when you select True
for A that True for C should be selected. You will need some sort of cross
reference table, I think. It is also important to know whether it will be
only one or could it be many. For example, if D is selected, should it be
set up so that F and R are selected? And, does it ever change? I mean if A
is selected, will C always be selected or could there be circumstances where
C might not be selected or instead of C, you may want Q. Now, to make it
more complicated, If you select A and C is automatically selected, you have a
rule that says when C is selected, select V. Would that mean that by
selecting A, you would also autmatically select C and V?

Hope I'm not over analyzing this, but how you approach it depends on what
the rules are.
 
As you said, in the after update of the first checkbox, change the data in
the table, rather than in the form using SQL:

If me.Checkbox = True Then
DoCmd.RunSQL "UPDATE YourTable SET OtherCheckbox = True WHERE
YourTable.Record = " & Me.Record
Else
DoCmd.RunSQL "UPDATE YourTable SET OtherCheckbox = False WHERE
YourTable.Record = " & Me.Record
End If

Of course, change the table, field and other names to what your db actually
has.
Note: If the "Record" field is not numric, you'll need to enclose it in
quotes:

DoCmd.RunSQL "UPDATE YourTable SET OtherCheckbox = True WHERE
YourTable.Record = '" & Me.Record & "'"
 
My answer to basically all of your questions is "yes". If A is selected,
then B will always be selected. I'm not sure if it will be necessary to add
more levels (i.e. if a=true, c=true and if c=true,d=true......so if
a=true,d=true) but I'd be interested to know if it was possible. Basically
if there's any way you know to automatically update C as being true when A is
true, than that would be a huge help. The only other detail i would like to
make note of is that the converse of the statement is not necessarily true
(if c, then a) so in my head it needs to go in an if statement checking if a
is true (because it is possible that c can be true and a can be false).

If you could elaborate on the idea of a cross reference table, that would be
great.

Thanks for your help!
 
I would recommend
Currentdb.Execute(""UPDATE YourTable SET OtherCheckbox = True WHERE
YourTable.Record = " & Me.Record), dbFailOnError

It is much faster than the RunSQL method because it goes directly to Jet
without having to go through the Access UI.
 
Back
Top