Numeric versus Long Integer

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • CLSkcab
    New Member
    • Aug 2014
    • 26

    #1

    Numeric versus Long Integer

    Background
    Frontend MS Access 2010 w/ VBA; Backend MS SQL Server 2008
    Just learning SQL

    My Problem

    I have a SQL table with a field named QTY and it is defined as numeric(18,0). It is being read into a field that is defined as DIM gblQTY as Long.

    Code:
    gblQTY = Nz(DLookup("QTY", "dbo_part Shortages", "[key] = '" & gblKey & "'"))
    When a table entry that has a 0 value is read I get the following error: runtime error "6" Overflow.

    Thanks in advanced.
  • twinnyfo
    Recognized Expert Moderator Specialist
    • Nov 2011
    • 3665

    #2
    If your code is accurate, you are not provided the Nz() function to return a value if the result is Null. Try:

    Code:
    gblQTY = Nz(DLookup("QTY", "dbo_part Shortages", _
        "[key] = '" & gblKey & "'"), 0)
    Also, a "key" is usually a numeric value. Your code indicates that it is a text field (the single quotes). Are you sure that it is a text value and not a numeric value?

    Comment

    Working...