Results 1 to 8 of 8
  1. #1
    ryanwales is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Oct 2011
    Posts
    27

    Make textbox from subform display and store in main form

    I have a quote form that facilitates the selection of multiple products. There is a main form (QuoteNew) and a subform (QuoteDetails).

    When product(s) are chosen and the total price (txtTotalPrice) is made, there is a textbox in the footer of the subform that caluclates the cumulative total of txtTotalPrice via a Sum function.



    I need this Sum (txtSum) to appear in txtQuoteSubtotal and for it to store as the subtotal in the quote table. I have been able to make txtSum appear in the txtQuoteSubtotal textbox but it wont save.

    Do i need to do an after update in txtSum? If so, what is the code?

    Thanks in advance

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,620
    Really should not be saving aggregate calc results.

    It will require code to save calculated values. If the field is included in the form's RecordSource, in VBA simply:
    Me!fieldname = Me.txtSum

    The trick is deciding what event to put this code in. Suggest in Click event of a button that closes the form then also disable the X close button.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    ryanwales is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Oct 2011
    Posts
    27
    Quote Originally Posted by June7 View Post
    Really should not be saving aggregate calc results.

    It will require code to save calculated values. If the field is included in the form's RecordSource, in VBA simply:
    Me!fieldname = Me.txtSum

    The trick is deciding what event to put this code in. Suggest in Click event of a button that closes the form then also disable the X close button.
    Hi June, thanks for the swift response! would that code work as there is a main form and subform involved?
    So the trick would be to have a button such as 'update price' where once clicked, txtSum would be passed from the subform to txtQuoteSubtotal in the main form?

  4. #4
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,640
    To make sure nobody goes over the same ground twice:

    https://www.accessforums.net/forms/m...orm-18366.html
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  5. #5
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,620
    Not quite. The textbox ControlSource would be an expression that is simply like (this syntax is tricky):
    =Forms!mainformname!subformcontainercontrol!textbo xname

    Name the subform container control different from the form it holds.

    The textbox will automatically recalc. The code is needed to save value to table. However, I repeat, saving aggregate data is usually not necessary and often bad design.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  6. #6
    ryanwales is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Oct 2011
    Posts
    27
    I can get txtSum to appear in txtQuoteSubtotal just by using [Child10].Form![txtSum] but I obviously want it to store as the subtotal since a record needs to be saved. that way, the total quote price can then be calculated.

    The idea of a 'container' seems alien to me, at least i'm not familiar with the term if i somehow know what it is, can you elaborate?

  7. #7
    June7's Avatar
    June7 is online now VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,620
    A subform is a form that is held by a subform container control. It is another control available on the control toolset. The container control has its own properties, such as the Master/Child links that synchronize the RecordSources of the forms. Click the edge of the subform, this selects the container. Click inside the edge and this selects the form.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  8. #8
    ryanwales is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Oct 2011
    Posts
    27
    And it's solved!! Thanks both, really appreciate it.

    I have one last problem and i'm done with it! heres the link to it:

    https://www.accessforums.net/forms/m...html#post87394

    Once again, thank you!

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

Similar Threads

  1. Replies: 2
    Last Post: 08-06-2011, 12:19 PM
  2. Replies: 2
    Last Post: 06-17-2010, 04:15 PM
  3. Subform won't display in main form
    By Lynn in forum Forms
    Replies: 15
    Last Post: 03-22-2010, 10:17 AM
  4. Can I make a subform display only?
    By nkenney in forum Forms
    Replies: 4
    Last Post: 04-01-2009, 11:50 AM
  5. Replies: 1
    Last Post: 02-27-2006, 07:46 AM

Tags for this Thread

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