Results 1 to 6 of 6
  1. #1
    uoghk is offline Competent Performer
    Windows 10 Office 365
    Join Date
    Jan 2022
    Posts
    149

    Run-time error -2147352567 (80020009)

    I have a form with subform inside as below photo.


    Click image for larger version. 

Name:	screen.jpg 
Views:	19 
Size:	166.9 KB 
ID:	47007
    When entering product in subform, it calculates the amount to ItemAmt.
    I want the ItemAmt auto-display in main form TotalAmt.
    So I add some coding on subform's EXIT event as below photo.
    Click image for larger version. 

Name:	error.jpg 
Views:	19 
Size:	63.9 KB 
ID:	47008
    When run, it shows the Run-time error -2147352567 (80020009).
    When debug, it stop at the yellow line and show the error.
    But if I press F8, it can step though the coding.
    How to fix it?
    Thanks.

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,815
    Saving aggregate data is usually unnecessary and often bad idea. If it can be calculated for saving, it can be calculated when needed.

    If you must save, then use code behind main form to save the value, not code behind subform.
    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
    uoghk is offline Competent Performer
    Windows 10 Office 365
    Join Date
    Jan 2022
    Posts
    149
    Thanks June7.
    If doing code behind in main form, how can I show the sum of ItemAmt in subform to the TotalAmt in main form?
    I try to code in main form's GetFocus event, but the TotalAmt still no change.

  4. #4
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,815
    Expression in textbox references subform control: =subformcontainername.Form.textboxname

    I always name container control different from object it holds, like: ctrItems

    Is the subform in Datasheet View?
    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.

  5. #5
    uoghk is offline Competent Performer
    Windows 10 Office 365
    Join Date
    Jan 2022
    Posts
    149
    The subform is not in Datasheet View.
    I set the main form textbox's control source = SubformName.Form.TextboxName
    Yes. the main form textbox can auto show the value in subform.
    But how to reference the main form textbox is matching to the data field in the table?

  6. #6
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,815
    If subform is not in Datasheet View, why would subform total need to be replicated on main form?

    Again, saving this aggregate value is really not necessary.

    What is main form name and subform container name?

    Code something like:

    Me!TotalAmt = Me.containername.Form.ItemTotal

    The real trick is figuring out what event to put this code into. Usually, this would be form BeforeUpdate event.
    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.

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

Similar Threads

  1. Replies: 3
    Last Post: 04-06-2021, 06:25 AM
  2. Replies: 5
    Last Post: 01-13-2017, 02:20 AM
  3. Replies: 0
    Last Post: 07-29-2016, 10:11 PM
  4. Replies: 8
    Last Post: 10-30-2015, 02:50 PM
  5. Replies: 0
    Last Post: 07-16-2012, 05:42 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