none
access database- Need help on Updating records that are included in other updating records RRS feed

  • Question

  • Greetings,

    I have an access database which consists of 2 tables :

    Table 1: Products

    Table 2: Items

    In the first table , I have these columns : 1- Name    2- Items   3-Products    4- Price

    ** Second column , in the above,  is the list of Items (from table 2)  that are used in each product.

    ** Third column , in the above,  is the list of other products (from table 1) , except itself,  that are used in each product.

    In the second table , I have these columns : 1-Name 2-Price

    Take a look at the example in the pictures :


    "  *1*2  " in the second picture means : Item with ID1 and Item with ID2. * is separator, as lines aren't allowed in cells.

    Price of products is sum of all included items or / and products

    I made an automatic updater program that can change and trace values of all involved records. For Example :  If I update Price of item1 to 20 , because Item1 is used in product 1 , it should update product 1 price as well : 30

    and because item 1 and  product 1 are used in the second product , it should change price of product 2 as well : 40

    SO far,  it was possible for me to make such a program and it works well.

    But what if 2 products are used in each other. For example , Imagine,  there is a third product that uses the second product and the second product that uses the third product. If I want to update each of these prices, there seems to be an infinite loop.

    My problem isn't with how to code the program , but it is about the generic/ rational calculation procedure I should follow to do so, Then I can code my program to do the procedure.

    ** and Also imagine a scenario in which only a single item's price is updated and that item is included in all those 3 products (and products are used in each other ...) What would happen ?





    • Edited by Kevin993 Wednesday, July 10, 2019 8:02 PM
    Wednesday, July 10, 2019 8:00 PM

All replies

  • Hi,

    Do you want to use vb.net to track the database?You can use Timer :

      Dim timer1 As Timer = New Timer With {.Enabled = True, .Interval = 1000}
            AddHandler timer1.Tick, Sub()
    
                                    End Sub

    If you want to use vb.net, I will give the complete code.

    Best Regards,

    Alex



    MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Thursday, July 11, 2019 2:08 AM
    Moderator
  • Hi,

    Do you want to use vb.net to track the database?You can use Timer :

      Dim timer1 As Timer = New Timer With {.Enabled = True, .Interval = 1000}
            AddHandler timer1.Tick, Sub()
    
                                    End Sub

    If you want to use vb.net, I will give the complete code.

    Best Regards,

    Alex



    MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.


    no need for a timer. the question isn't about how to track changes in coding.

    • Edited by Kevin993 Thursday, July 11, 2019 7:12 AM
    Thursday, July 11, 2019 7:12 AM
  • Hi,

    I didn't understand what you mean. You better explain your issue in detail. What project did you build?

    Best Regards,

    Alex


    MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    Tuesday, July 16, 2019 5:33 AM
    Moderator
  • Hi,

    I didn't understand what you mean. You better explain your issue in detail. What project did you build?

    Best Regards,

    Alex


    MSDN Community Support Please remember to click "Mark as Answer" the responses that resolved your issue, and to click "Unmark as Answer" if not. This can be beneficial to other community members reading this thread. If you have any compliments or complaints to MSDN Support, feel free to contact MSDNFSF@microsoft.com.

    sorry for answering late, I kinda lost my access to my account

    Well, after searching a lot about the question, it seems out that there is no absolute answer! This is like the question that asks whether hen was created first or egg.

    When 2 items contain each other (For e.g. A contains B and B contains A) , there would be an infinitive loop updating one of them as each update changes the already updated one .


    • Edited by Kevin993 Sunday, July 28, 2019 8:14 PM
    Sunday, July 28, 2019 8:13 PM