Welcome to SPN

Register and Join the most happening forum of Sikh community & intellectuals from around the world.

Sign Up Now!

help w/ table/form problems

Discussion in 'Information Technology' started by aheath15, Jul 28, 2006.

  1. aheath15

    aheath15
    Expand Collapse
    Guest

    I 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.
     
  2. Loading...


  3. strive4peace

    strive4peace
    Expand Collapse
    Guest

    make a table with the product dependencies

    *ProdPrereqs* (or a better name if you have one ;) )
    ProdPreID, autonumber
    ProductID_A, long integer -- if this is ordered...
    ProductID_B, long integer -- ... also order this
    Qty, number -- qty of B for each one of A

    Then, you can use an APPEND query to add records

    assuming this is your structure:

    *OrderDetails*
    OrdDetID, atuonumber
    OrderID, long integer
    ProductID, long integer
    Qty, number
    etc.
    DateCreate, date, DefaultValue --> =Now()

    You could use the form AfterInsert event behind the
    OrderDetails form

    '~~~~~~~~~~~~~~~~~~~~~
    dim s as string
    s = "INSERT INTO OrderDetails " _
    & " (OrderID, ProductID, Qty) " _
    & " SELECT " & me.orderID _
    & ", ProductID_B" _
    & ", Qty * " & me.qty _
    & " FROM ProdPrereqs " _
    & " WHERE ProductID_A = " _
    & me.ProductID & ";"
    debug.print s
    currentdb.execute s
    currentdb.tabledefs.refresh
    DoEvents
    me.requery
    '~~~~~~~~~~~~~~~~~~~~~

    now, the problem will be what to do if you want to edit a
    record -- this code only runs for new records. You need to
    devise a strategy for handling changes (or just leave that
    up to the user to correlate)


    Warm Regards,
    Crystal
    Microsoft Access MVP 2006

    *
    Have an awesome day ;)

    remote programming and training
    strive4peace2006 at yahoo.com

    *

    aheath15 wrote:
    > I 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.
     

Share This Page