Results 1 to 2 of 2
  1. #1
    ShostyFan is offline Advanced Beginner
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jan 2013
    Posts
    76

    Change data in subform from form ComboBox

    a simplified version of my problem is this:


    I have a form called Receipts and a sub form called Receipt Details. If a receipt and its details are saved I would like to be able to go back to the receipt and change a comboBox from Sale to Return and have the Qty's in the receipt details autoChange to a negative qty. So 1 would become -1 and so on.
    Any help on this would great!

  2. #2
    ketbdnetbp is offline Competent Performer
    Windows 7 32bit Access 2003
    Join Date
    Mar 2011
    Location
    Midwest
    Posts
    254
    ShostyFan -

    I used the following code to change quantities from positive to negative, in a subform, a while back. Unfortunately, I don’t have the time to re-write using your specifications so, it is provided, "As Is". You should be able to adapt it to your table/field/form names and situation. This code assumes there is a 1/M relationship between SalesTBL and SalesDetailsTBL using the SalesID.

    'In the AfterUpdate Event of the Combo, you could try…

    If Not IsNull(Me![NameofCombo]) And Me![NameOfCombo] = "Return" then

    Dim mySQL As String
    mySQL = "UPDATE SalesTBL INNER JOIN SalesDetailsTBL ON SalesTBL.SalesID = SalesDetailsTBL.SalesID" & _
    " SET SalesDetailsTBL.CSQTY = ([CSQTY]-([CSQTY]*2))" & _
    " WHERE (((SalesDetailsTBL.SalesID)=[Forms]![SalesTBLFRM]![SalesID]));"
    DoCmd.SetWarnings False
    DoCmd.RunSQL mySQL
    DoCmd.SetWarnings True
    [Forms]![SalesTBLFRM]![qrySalesDetailsTBL1Subform].Form.Requery

    Else
    '?????

    End if

    The expression ([CSQTY]-([CSQTY]*2)) should produce a negative number.

    A note of caution, anytime data is changed in such a profound way, you may need a way to check if the person doing the change has the authority/permission. Lastly, you should also have a method set-up that can reverse the change. You may be able to use the Abs() function in this regard.

    Hope this helps,

    Jim

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Replies: 2
    Last Post: 05-17-2012, 11:19 AM
  2. Replies: 1
    Last Post: 09-06-2011, 01:47 PM
  3. Replies: 29
    Last Post: 08-16-2011, 05:52 PM
  4. Replies: 0
    Last Post: 08-24-2010, 06:38 PM
  5. Replies: 0
    Last Post: 12-16-2009, 01:14 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums