Results 1 to 13 of 13

Thread: #Size Error

  1. #1
    thedanch is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jun 2012
    Posts
    22

    #Size Error

    Hi,

    I'm making a form. There are three subforms in it, all with unbound text boxes that calculate the sum of one of the columns. In the main form, there's then an unbound text box which sums those three subtotals.

    It works fine as long as none of the values are null. If one's null I get a #type error, so I changed the formula to
    Code:
    =Nz([Labor_WIP subform].[Form]![LaborWIPSubtotal],0)+Nz([Vehicle_WIP subform].[Form]![KMWIPSubtotal],0)+Nz([EquipmentWIP subform].[Form]![EquipmentWIPSubotal],0)
    But now I'm getting a #size error instead... Again, it works fine, as long as there are no null's in there, but a null throws it off.

    Any ideas on how to fix that? Or what even causes a #size error?

    Thanks

  2. #2
    pbaldy's Avatar
    pbaldy is online now Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    11,430
    See if this helps:

    nnz function
    Paul (wino moderator)
    MS Access MVP
    www.BaldyWeb.com

  3. #3
    thedanch is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jun 2012
    Posts
    22
    Thanks pBaldy.
    I created the function but now I'm getting a #name error with the following code:

    Code:
    =nnz([Vehicle_WIP subform].[Form]![KMWIPSubtotal])+
    nnz([Labor_WIP subform].[Form]![LaborWIPSubtotal])+
    nnz([EquipmentWIP subform].[Form]![EquipmentWIPSubotal])

  4. #4
    pbaldy's Avatar
    pbaldy is online now Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    11,430
    Did you put the function in a standard module? Can you post the db here?
    Paul (wino moderator)
    MS Access MVP
    www.BaldyWeb.com

  5. #5
    thedanch is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jun 2012
    Posts
    22
    I'm unable to post the db, but I think the function is in a standard module. Access recognizes it as a function, and I did I direct copy/paste of the code.

    Code:
    
    'This code was originally written by Keri Hardwick.
    'It is not to be altered or distributed,
    'except as part of an application.
    'You are free to use it in any application,
    'provided the copyright notice is left unchanged.
    '
    'Code Courtesy of
    'Keri Hardwick
    '
    Function Nnz(testvalue As Variant) As Variant
    'Not Numeric return zero
        If Not (IsNumeric(testvalue)) Then
            Nnz = 0
        Else
            Nnz = testvalue
        End If
    End Function

  6. #6
    pbaldy's Avatar
    pbaldy is online now Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    11,430
    Is any VBA running? The database has to be in a trusted location, or you have to have explicitly enabled code. I just did a quick test and this worked:

    =nnz([tblTestsubform].[Form].[txtsubtotal])
    Paul (wino moderator)
    MS Access MVP
    www.BaldyWeb.com

  7. #7
    thedanch is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jun 2012
    Posts
    22
    There's a bit of VBA code on the form as follows:

    Code:
    Option Compare Database
    
    
    
    
    
    
    Private Sub Client_AfterUpdate()
    
    
        Form.Refresh
        
    End Sub
    
    
    
    
    Private Sub Province_AfterUpdate()
    
    
       Form.Refresh
        
    End Sub
    And that runs fine. The #name error indicates that it's not recognizing the function, correct?

  8. #8
    RayMilhon is offline Expert
    Windows XP Access 2010 32bit
    Join Date
    Aug 2011
    Location
    Southern California
    Posts
    713
    As a general rule I include the Option Explicit under the Option Compare Database in every module including vba modules behind reports and forms. It'll help identify potential typing errors in the module when you compile

  9. #9
    pbaldy's Avatar
    pbaldy is online now Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    11,430
    Quote Originally Posted by RayMilhon View Post
    As a general rule I include the Option Explicit under the Option Compare Database in every module including vba modules behind reports and forms. It'll help identify potential typing errors in the module when you compile
    So do I:

    http://www.baldyweb.com/OptionExplicit.htm

    The #Name error could mean it doesn't recognize the function, or that something is spelled wrong.
    Paul (wino moderator)
    MS Access MVP
    www.BaldyWeb.com

  10. #10
    thedanch is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jun 2012
    Posts
    22
    Thanks for the Explicit tip...

    Yeah - spelling's right. Module's loaded and showing up on the sidebar... If I start typing Nnz Access prompts me as if it's a function. So I'm stumped.

  11. #11
    pbaldy's Avatar
    pbaldy is online now Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    11,430
    You didn't name the module the same as the function, did you? That will confuse Access, so it can't have the same name.
    Paul (wino moderator)
    MS Access MVP
    www.BaldyWeb.com

  12. #12
    thedanch is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Jun 2012
    Posts
    22
    Yep - that would be it. Works now!

    Thanks a ton for the help.

  13. #13
    pbaldy's Avatar
    pbaldy is online now Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    11,430
    No problemo!
    Paul (wino moderator)
    MS Access MVP
    www.BaldyWeb.com

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

Similar Threads

  1. Replies: 3
    Last Post: 07-19-2012, 08:27 AM
  2. Replies: 0
    Last Post: 07-16-2012, 04:42 AM
  3. Field size error
    By Newbie11 in forum Forms
    Replies: 8
    Last Post: 12-26-2011, 06:15 PM
  4. Any way to set box size?
    By kman42 in forum Reports
    Replies: 2
    Last Post: 04-17-2011, 03:19 PM
  5. After error database have less size
    By Douglasrac in forum Access
    Replies: 3
    Last Post: 03-31-2011, 06:16 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
  •  
Tech Forums: Microsoft Office Forums