Page 2 of 2 FirstFirst 12
Results 16 to 21 of 21
  1. #16
    Gicu's Avatar
    Gicu is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jul 2015
    Location
    Kelowna, BC, Canada
    Posts
    4,118
    Here you are, please have a look; all was needed is to wrap the DSum expressions in NZ().



    Cheers,
    Attached Files Attached Files
    Vlad Cucinschi
    MS Access Developer
    http://forestbyte.com/

  2. #17
    jazzy is offline Advanced Beginner
    Windows 10 Office 365
    Join Date
    Nov 2021
    Posts
    77
    this code returns it back to first record of subform
    Code:
    Private Sub Form_AfterUpdate()
    
    Dim RecordID As Long
    
    
    Application.Echo False 'turn off screen updating
    RecordID = Me.InvoiceLineItemID 'store the current ID
    
    
    Form_frm_Invoice.InvoicePayments = DSum("[LineTotal]", "qry_InvoiceLineItemPayments", "InvoiceID =" & Form_frm_Invoice.InvoiceIDBOX)
    Form_frm_Invoice.InvoiceAddendums = DSum("[LineTotal]", "qry_InvoiceLineItemAddendums", "InvoiceID =" & Form_frm_Invoice.InvoiceIDBOX)
    Me.InvoiceLineItemID.SetFocus
    DoCmd.FindRecord RecordID 'get back to starting record
    DoCmd.GoToRecord , , acNext ' comment this out if you want to stay where you started
    Application.Echo True 'turn on screen updating
    End Sub
    This Code Works but seems excessive
    Code:
    Private Sub Form_AfterUpdate()
    
    Dim RecordID As Long
    
    
    Application.Echo False 'turn off screen updating
    RecordID = Me.InvoiceLineItemID 'store the current ID
    
    
    Form_frm_Invoice.InvoicePayments = DSum("[LineTotal]", "qry_InvoiceLineItemPayments", "InvoiceID =" & Form_frm_Invoice.InvoiceIDBOX)
    Me.InvoiceLineItemID.SetFocus
    DoCmd.FindRecord RecordID 'get back to starting record
    DoCmd.GoToRecord , , acNext ' comment this out if you want to stay where you started
    Application.Echo True 'turn on screen updating
    
    
    Form_frm_Invoice.InvoiceAddendums = DSum("[LineTotal]", "qry_InvoiceLineItemAddendums", "InvoiceID =" & Form_frm_Invoice.InvoiceIDBOX)
    Me.InvoiceLineItemID.SetFocus
    DoCmd.FindRecord RecordID 'get back to starting record
    DoCmd.GoToRecord , , acNext ' comment this out if you want to stay where you started
    Application.Echo True 'turn on screen updating
    
    
    End Sub
    Thoughts?

  3. #18
    Gicu's Avatar
    Gicu is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jul 2015
    Location
    Kelowna, BC, Canada
    Posts
    4,118
    Did you try to wrap the DSums in the Nz() function as I showed you in post #16?
    Code:
    Private Sub Form_AfterUpdate()
    Dim curPayment As Currency, curAddendums As Currency
    curPayment = Nz(DSum("[LineTotal]", "qry_InvoiceLineItemPayments", "InvoiceID =" & Form_frm_Invoice.InvoiceIDBOX))
    curAddendums = Nz(DSum("[LineTotal]", "qry_InvoiceLineItemAddendums", "InvoiceID =" & Form_frm_Invoice.InvoiceIDBOX))
    'update parent form
    Form_frm_Invoice.InvoicePayments = curPayment 'DSum("[LineTotal]", "qry_InvoiceLineItemPayments", "InvoiceID =" & Form_frm_Invoice.InvoiceIDBOX)
    Form_frm_Invoice.InvoiceAddendums = curAddendums 'DSum("[LineTotal]", "qry_InvoiceLineItemAddendums", "InvoiceID =" & Form_frm_Invoice.InvoiceIDBOX)
    Current event of the subform_Invoice:
    Code:
    Form_frm_Invoice.InvoicePayments = Nz(DSum("[LineTotal]", "qry_InvoiceLineItemPayments", "InvoiceID =" & Form_frm_Invoice.InvoiceIDBOX))
    Form_frm_Invoice.InvoiceAddendums = Nz(DSum("[LineTotal]", "qry_InvoiceLineItemAddendums", "InvoiceID =" & Form_frm_Invoice.InvoiceIDBOX))
    And same on the Open event of the frmInvoice.

    Cheers,
    Vlad Cucinschi
    MS Access Developer
    http://forestbyte.com/

  4. #19
    jazzy is offline Advanced Beginner
    Windows 10 Office 365
    Join Date
    Nov 2021
    Posts
    77
    completely missed this..... new to the forum. thank you very much

  5. #20
    jazzy is offline Advanced Beginner
    Windows 10 Office 365
    Join Date
    Nov 2021
    Posts
    77
    GICU thank you very much

  6. #21
    Gicu's Avatar
    Gicu is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jul 2015
    Location
    Kelowna, BC, Canada
    Posts
    4,118
    Quote Originally Posted by jazzy View Post
    GICU thank you very much
    You're very welcome 😉!
    Vlad Cucinschi
    MS Access Developer
    http://forestbyte.com/

Page 2 of 2 FirstFirst 12
Please reply to this thread with any new information or opinions.

Similar Threads

  1. Requery Subform from combo box on Main Form
    By Topflite66 in forum Forms
    Replies: 6
    Last Post: 04-03-2020, 01:13 PM
  2. Replies: 2
    Last Post: 11-15-2017, 08:51 AM
  3. Requery subform from main form
    By nswhit in forum Forms
    Replies: 7
    Last Post: 05-13-2013, 02:22 PM
  4. Requery subform after update of main form
    By gemadan96 in forum Forms
    Replies: 3
    Last Post: 10-17-2012, 02:33 PM
  5. Replies: 3
    Last Post: 04-17-2012, 10:28 AM

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