Results 1 to 4 of 4
  1. #1
    data808 is offline Noob
    Windows 8 Access 2007
    Join Date
    Aug 2012
    Posts
    727

    Help with Code

    I have this going right now but it doesn't seem to be working:



    Private Sub txtSumAmtsDue1_LostFocus()

    If Me.txtSumAmtsDue1 Is Dirty(txtSumAmtsDue1) Then
    Me.txtAmtDue = Nz([txtSumAmtsDue1], 0) + Nz([txtSumAmtsDue2], 0) + Nz([txtSumAmtsDue3], 0) + Nz([txtSumAmtsDue4], 0) _
    + Nz([txtSumAmtsDue5], 0) + Nz([txtSumAmtsDue6], 0) + Nz([txtSumAmtsDue7], 0)
    Me.txtChange = Me.txtCHK + Me.txtCHRG + Me.txtCashGiven - Me.txtAmtDue
    End If

    End Sub

    I need for this text box "txtSumAmtsDue1" to only sum up everything if its dirty. Can anyone assist please?

  2. #2
    Missinglinq's Avatar
    Missinglinq is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    May 2012
    Location
    Richmond (Virginia, not North Yorkshire!)
    Posts
    3,018
    Drop the If...Then...End If construct and place the calculation in the txtSumAmtsDue1_AfterUpdate event. This event will only fire if txtSumAmtsDue1 is dirty, which does away with the need to test for it being dirty.

    BTW, pretty sure that Is Dirty() is not a VBA function.

    Linq ;0)>

  3. #3
    data808 is offline Noob
    Windows 8 Access 2007
    Join Date
    Aug 2012
    Posts
    727
    Thanks Missinglinq. Works like a charm.

  4. #4
    Missinglinq's Avatar
    Missinglinq is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    May 2012
    Location
    Richmond (Virginia, not North Yorkshire!)
    Posts
    3,018
    VBA code is kind of like real estate...the important thing is location, location, location!

    Linq ;0)>

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

Similar Threads

  1. Replies: 4
    Last Post: 03-10-2014, 12:18 PM
  2. Report Code is not allowing return to main code
    By rcwiley in forum Programming
    Replies: 2
    Last Post: 06-16-2013, 10:31 AM
  3. Replies: 7
    Last Post: 05-28-2013, 09:11 AM
  4. Replies: 1
    Last Post: 05-04-2013, 12:19 PM
  5. Word code in Access - How to modify my current code
    By Alexandre Cote in forum Programming
    Replies: 0
    Last Post: 11-15-2010, 08:26 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