Results 1 to 10 of 10
  1. #1
    Join Date
    May 2006
    Posts
    386

    Unanswered: Please help, my database suddently keeps giving me Runtime Error 6, Overflow

    Dear All,

    I have been using my database all day today and just an hour ago, when I try to raise invoice using the database, I get this error:

    Runtime Error 6, over flow
    and when I click on Debug, the following line is highlighted in yelow

    Generate_Sage_Invoice = oInvoicePost.Header("INVOICE_NUMBER").Value
    Any help would be much appreciated as I am stressed out.
    Last edited by Emal; 05-25-11 at 12:04. Reason: the heading was not written properly
    Emi-UK
    Love begets Love, Help Begets Help

  2. #2
    Join Date
    Mar 2009
    Posts
    5,441
    Provided Answers: 14
    What's Generate_Sage_Invoice and how is it defined? What's the content (.Value) of oInvoicePost.Header("INVOICE_NUMBER") and how is it defined? This kind of error happens when you try to assign a value to someting (a variable, a property) and that this value is out of the range capacity of the recipient (too large or too small).
    Have a nice day!

  3. #3
    Join Date
    May 2006
    Posts
    386
    Hi Sinndho, Thank you for your response.
    Generate_Sage_Invoice = oInvoicePost.Header("INVOICE_NUMBER").Value is basically the line that tells the database to generate an invoice number from Sage Accounting software.
    Emi-UK
    Love begets Love, Help Begets Help

  4. #4
    Join Date
    Mar 2009
    Posts
    5,441
    Provided Answers: 14
    That's not what I'm asking for. To understand what happens we need to know what's the definition of Generate_Sage_Invoice (its data type) and what oInvoicePost.Header("INVOICE_NUMBER") contains when the error occurs.
    Have a nice day!

  5. #5
    Join Date
    May 2006
    Posts
    386
    OK, basically following is part of the code used for raising an invoice and as soon as I click on the command button to raise the invoice, the error pops up. There were more features and codes that I dont think are relevant.

    Private Function Generate_Sage_Invoice(ByVal BookingID As String) As Integer
    ' Error Handler

    Dim oSDO As SageDataObject120.SDOEngine
    Dim oWS As SageDataObject120.Workspace
    Dim oInvoicePost As SageDataObject120.InvoicePost
    Dim oInvoiceItem As SageDataObject120.InvoiceItem
    Dim oSalesRecord As SageDataObject120.SalesRecord


    Dim szDataPath As String
    Dim iCtr As Long


    Set oSDO = New SageDataObject120.SDOEngine

    Set oWS = oSDO.Workspaces.Add("Example")

    szDataPath = oSDO.SelectCompany("C:\Program Files\Sage\Accounts")

    If szDataPath <> "" Then

    ' Try to Connect - Will throw an exception if it fails
    If oWS.Connect(szDataPath, "password", "user", "Example") Then

    ' Create an instance of InvoicePost & Record objects
    Set oSalesRecord = oWS.CreateObject("SalesRecord")
    Set oInvoicePost = oWS.CreateObject("InvoicePost")

    ' Set the type of invoice so we can find the next available number
    oInvoicePost.Type = sdoLedgerService

    ' Use the GetNextNumber Method to generate the next available number
    oInvoicePost.Header("INVOICE_NUMBER").Value = CLng(oInvoicePost.GetNextNumber)

    'Find the relevant customer
    oSalesRecord.Fields.Item("ACCOUNT_REF").Value = CStr(Me.Recordset.Fields("Client.id").Value)

    ' Perform Exact match find
    bFlag = oSalesRecord.Find(False)

    If bFlag Then

    GoTo continue

    Else

    MsgBox "The invoice could not be raised" & vbNewLine & vbNewLine & "Please create the customer before invoicing", vbOKOnly Or vbInformation, "Invoice"
    Exit Function

    End If

    continue:
    Dim InvoiceTotal As Double
    InvoiceTotal = 0

    ' This is the main CleaningService line
    If IsNull(Me.WorkHrsClient) = False Then
    Set oInvoiceItem = oInvoicePost.Items.Add()
    oInvoiceItem.Text = CStr("CleaningService")
    oInvoiceItem.Fields.Item("TEXT").Value = CStr("CleaningService")
    oInvoiceItem.Fields.Item("QTY_ORDER").Value = CDbl(Val(Me.WorkHrsClient))

    End If

    If IsNull(Me.WorkHrsClient) = False Then
    InvoiceTotal = InvoiceTotal + Round(CDbl(Val(Me.WorkHrsClient) * Val(Me.ClientRate)), 2)
    End If


    'Update the Invoice
    If oInvoicePost.Update Then

    MsgBox "Invoice is created successfully", vbOKOnly, "Invoice"

    Generate_Sage_Invoice = oInvoicePost.Header("INVOICE_NUMBER").Value

    Else

    MsgBox "Invoice Not Created", vbOKOnly, "Invoice"

    End If

    ' Disconnect
    oWS.Disconnect


    End If

    End If

    ' Destroy Objects
    Set oSalesRecord = Nothing
    Set oInvoicePost = Nothing
    Set oInvoiceItem = Nothing
    Set oWS = Nothing
    Set oSDO = Nothing

    Exit Function

    ' Error Handling Code
    Error_Handler:

    MsgBox "The SDO generated the following error: " & oSDO.LastError.Text, vbOKOnly, "Invoice"

    End Function
    Emi-UK
    Love begets Love, Help Begets Help

  6. #6
    Join Date
    Mar 2009
    Posts
    5,441
    Provided Answers: 14
    Just a wild guess but try:
    Code:
    Private Function Generate_Sage_Invoice(ByVal BookingID As String) As Variant
    Have a nice day!

  7. #7
    Join Date
    May 2006
    Posts
    386
    SINNDHO!!! You are a Genius. I sincerely do not now how to thank you. It worked beautifully as it used to work. Thank you very much. But I dont know how it suddenly stopped working when it was working like this for many years.
    Emi-UK
    Love begets Love, Help Begets Help

  8. #8
    Join Date
    Mar 2009
    Posts
    5,441
    Provided Answers: 14
    You're welcome!
    Have a nice day!

  9. #9
    Join Date
    May 2011
    Posts
    8
    overflow could be the result of a div by zero error

    not sure if changing the function to a variant would mask that problem.

  10. #10
    Join Date
    Mar 2009
    Posts
    5,441
    Provided Answers: 14
    A division by zero yields error 11, not error 6.
    Attached Thumbnails Attached Thumbnails DivZero_Err.jpg  
    Have a nice day!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •