• Updating Field from a textbox on a form (Access 2000)

    Home » Forums » AskWoody support » Productivity software by function » MS Access and database help » Updating Field from a textbox on a form (Access 2000)

    Author
    Topic
    #400437

    I have three tables STOCK, RESTOCK, USED.

    And one form with two subforms (FMSTOCK, SUBFMRESTOCK and SUBFMUSED). The form is based on the STOCK table, and the two subforms are based on RESTOCK, and USED.

    I have a textbox in FMSTOCK called TOTAL which subtracts the total in SUBFMUSED from the total in SUBFMRESTOCK, to show me how many of the item I have left.

    This all works fine.

    Unfortunately I cannot work out how to get the number shown in the textbox TOTAL to replace the amount of stock shown in the STOCK table (need to do this to make it easy to run a reorder report) when I add records to either RESTOCK, or USED. I cannot link the textbox TOTAL direct using the control source, as the control source is set to subtract the totals from the textbox’s in the two subforms ( ie =[subrestock]-[subtaken] )

    I have tried to use an update query, which is run through a macro via the onchange, and on update options in the properties of the TOTAL textbox on the FMSTOCK form. Nothing happens. I have tried to add a textbox which uses the field AMOUNT from the STOCK table as the control source, which would then update to the TOTAL textbox when the TOTAL textbox changes. Again nothing happens.

    Please help.

    Viewing 1 reply thread
    Author
    Replies
    • #781281

      In general, storing a calculated value in a table is not a good idea. From your description, it seems to me that it wouldn’t be too difficult to create a query that calculates TOTAL on the fly; you could use this query for the reorder report.

      However, if you really need to store the value, I would bind the TOTAL text box to the corresponding field in the STOCK table. Update TOTAL in the After Update event of both subforms, something like Me.Parent.TOTAL = Me.Parent.[SubRESTOCK] – Me.Parent.[SubTAKEN] (the situation is not quite clear to me, so you may have to adapt this.)

    • #781282

      In general, storing a calculated value in a table is not a good idea. From your description, it seems to me that it wouldn’t be too difficult to create a query that calculates TOTAL on the fly; you could use this query for the reorder report.

      However, if you really need to store the value, I would bind the TOTAL text box to the corresponding field in the STOCK table. Update TOTAL in the After Update event of both subforms, something like Me.Parent.TOTAL = Me.Parent.[SubRESTOCK] – Me.Parent.[SubTAKEN] (the situation is not quite clear to me, so you may have to adapt this.)

    Viewing 1 reply thread
    Reply To: Updating Field from a textbox on a form (Access 2000)

    You can use BBCodes to format your content.
    Your account can't use all available BBCodes, they will be stripped before saving.

    Your information: