Results 1 to 2 of 2

Thread: Hey gurus here's a challenge for you!

  1. #1

    Thread Starter
    New Member
    Join Date
    Aug 2000
    Posts
    15

    Unhappy

    I'm having a little problem trapping errors in a text file without crashing the program. This is a part of a program that makes a report from data in a database. I added a error reporting function (below) to help me debug problems for customers. Now though it crashes the program and doesn't print anything!! WHY??
    I put a errhndlr routine at the end of the second chunk of code, it resides in the program as a goto statement.




    Public Function LogError(ByVal ErrDateTime As Date, ByVal procname As String, ByRef ErrObj As ErrObject, Optional FormObject As Object, Optional CommandString As String)
    Dim intFileO As Integer
    ErrDateTime = (Date)

    On Error Resume Next

    intFileO = IntFile(0)
    MsgBox ("An error occured, and a Log file is being created")
    Open App.Path & "\Error.log" For Append As intFileO

    If IsMissing(FormObject) And IsMissing(CommandString) Then
    Write #intFileO, ErrDateTime, procname, ErrObj.Description,
    ErrObj.Source
    ElseIf Not IsMissing(FormObject) And Not IsMissing(CommandString) Then
    Write #intFileO, ErrDateTime, procname, ErrObj.Description,
    ErrObj.Source , FormObject.Caption, CommandString
    ' a routine to dump all values found in a form
    Call DumpFormValues(intFileO, frmRecordCard)
    ElseIf Not IsMissing(CommandString) Then
    Write #intFileO, ErrDateTime, procname, ErrObj.Description,
    ErrObj.Source , CommandString
    End If

    Close intFileO
    On Error GoTo 0
    Err.Clear
    On Error GoTo errhndlr
    End Function
    errhndlr: Call LogError(ErrDateTime, procname, ErrObj, FormObject, CommandString)
    End Function







    Public Sub commercial()
    procname = "commercial"
    Dim zz As Integer
    Dim rover As Integer
    On Error Resume Next
    On Error GoTo errhndlr
    Call grprint("Buildings", 300, 6941, 5054, "L")
    Call grprint("Bldg", 228, 7171, 1032, "L")
    Call grprint("Sec", 614, 7171, 1032, "L")
    Call grprint("Occ", 969, 7171, 1032, "L")
    Call grprint("Desc", 1400, 7171, 1100, "L")
    Call grprint("Year", 2822, 7171, 1032, "L")
    Call grprint("Cls", 3301, 7171, 1032, "L")
    Call grprint("Qual", 3734, 7171, 1032, "L")
    Call grprint("Cond", 4187, 7171, 1032, "L")
    Call grprint("Area", 4753, 7171, 1032, "L")
    Call grprint("Perm", 5247, 7171, 1032, "L")
    Call grprint("Stor", 5900, 7171, 1032, "L")
    Call grprint("Hght", 6383, 7171, 1032, "L")
    Call grprint("SecRCN", 6864, 7171, 1032, "L")
    Call grprint("Phys", 7901, 7171, 1032, "L")
    Call grprint("Func", 8374, 7171, 1032, "L")
    Call grprint("RCNLD", 8907, 7171, 1032, "L")

    rover = 7171

    If rdoOutBldg.Resultset.rowcount > 1 Then
    rdoOutBldg.Resultset.movefirst
    CommandString = "rdooutbldg.resultset.rowcount >1"
    End If
    tctr1 = 1
    If tctr1 < 7 Then 'prevents overprint
    For zz = 1 To rdoOutBldg.Resultset.rowcount
    rover = rover + 180 'adds 180 to rover to advance print line for buildings
    Call grprint(rdoOutBldg.Resultset("LINK"), 228, rover, 900, "L")
    Call grprint(rdoOutBldg.Resultset("SECTION_NUMBER"), 614, rover, 900, "L")
    Call grprint(rdoOutBldg.Resultset("OCC_CODE"), 969, rover, 900, "L")
    Call grprint(rdoOutBldg.Resultset("DESCRIPTION"), 1400, rover, 1368, "L")
    Call grprint(rdoOutBldg.Resultset("YEAR_BUILT"), 2772, rover, 1000, "L")
    Call grprint(rdoOutBldg.Resultset("CLASS"), 3351, rover, 1000, "L")
    Call grprint(rdoOutBldg.Resultset("QUALITY"), 3714, rover, 1000, "L")
    Call grprint(rdoOutBldg.Resultset("CONDITION"), 4187, rover, 1000, "L")
    Call grprint(Format(rdoOutBldg.Resultset("TOTAL_AREA"), "###,###,###"), 4613, rover, 1000, "L")
    Call grprint(Format(rdoOutBldg.Resultset("PERIMETER"), "###,###,###"), 5187, rover, 1000, "L")
    Call grprint(Format(rdoOutBldg.Resultset("STORIES"), "###,###,###"), 5900, rover, 1000, "L")
    Call grprint(rdoOutBldg.Resultset("STORY_HT"), 6383, rover, 1000, "L")
    Call grprint(Format(rdoOutBldg.Resultset("SECTION_RCN"), "###,###,###"), 6854, rover, 1000, "L")
    Call grprint(Format(rdoOutBldg.Resultset("PHYSICAL"), "00.00%"), 7741, rover, 1000, "L")
    Call grprint(Format(rdoOutBldg.Resultset("FUNCTIONAL"), "00.00%"), 8374, rover, 1000, "L")
    Call grprint(Format(rdoOutBldg.Resultset("TOTAL_VALUE"), "###,###,###"), 8937, rover, 1000, "L")
    rdoOutBldg.Resultset.MoveNext
    CommandString = "rdoOutbldg.resultset(fieldx)"
    tctr1 = tctr1 + 1
    Next zz
    End If

    Printer.Line (5155, 10870)-(5155, 11480) ' Cost Appr Box this should close the little box for marshal and swift
    Printer.Line (92.05, 9040)-(9602, 9040), Val(&H8000000F), BF ' printing the refinements
    Printer.Line (89.05, 8800)-(9602, 8800), Val(&H8000000F), BF
    Printer.Line (89.05, 8800)-(2000, 9040), Val(&H8000000F), BF


    Call grprint("Refinements >>", 200, 8880, 1532, "L")
    Call grprint("Bldg", 2322, 8880, 1032, "L")
    Call grprint("Code", 2851, 8880, 1032, "L")
    Call grprint("Desc", 3434, 8880, 1032, "L")
    If StateName <> "NE" Then
    Call grprint("Year", 5147, 8880, 1032, "L")
    End If
    Call grprint("# Units", 5900, 8880, 1032, "L")
    Call grprint("$/Unit", 6583, 8880, 1032, "L")
    Call grprint("RCN", 7304, 8880, 1032, "L")
    Call grprint("Depr", 8101, 8880, 1032, "L")
    Call grprint("Value", 8674, 8880, 1032, "L")

    If rdoMiscImpr.Resultset.rowcount = Null Then
    CommandString = "rdoMiscImpr.resultset.rowcount"
    Else
    If rdoMiscImpr.Resultset.rowcount > 1 Then
    rdoMiscImpr.Resultset.movefirst
    End If

    rover = 8880
    tctr1 = 1
    If tctr1 < 7 Then ' prevents overprint
    For zz = 1 To rdoMiscImpr.Resultset.rowcount
    rover = rover + 180 'adds 180 to rover to advance print line for Refinements
    Call grprint(rdoMiscImpr.Resultset("Bldg_Number"), 2322, rover, 900, "L")
    Call grprint(rdoMiscImpr.Resultset("Code"), 2851, rover, 900, "L")
    Call grprint(rdoMiscImpr.Resultset("Description"), 3434, rover, 1700, "L")
    If StateName = "NE" Or StateName = "MO" Then
    ' for Ne development quick fix, since NE development has a different field name than
    ' NE distribution for year, I'm just ignoring errors and printing the same field, but
    ' for both versions,
    On Error Resume Next
    Call grprint(rdoMiscImpr.Resultset("Year"), 5147, rover, 900, "L")
    Err.Clear
    Call grprint(rdoMiscImpr.Resultset("Year_in"), 5147, rover, 900, "L")
    Err.Clear
    On Error GoTo errhndlr
    End If
    If StateName = "SD" Then
    Call grprint(rdoMiscImpr.Resultset("Year_In"), 5247, rover, 900, "L")
    End If
    Call grprint(rdoMiscImpr.Resultset("Units"), 5900, rover, 900, "L")
    Call grprint(rdoMiscImpr.Resultset("Cost"), 6583, rover, 900, "L")
    Call grprint(Format(rdoMiscImpr.Resultset("RCN"), "###,###,###"), 7304, rover, 900, "L")
    Call grprint(rdoMiscImpr.Resultset("Depr_%"), 8101, rover, 900, "L")
    Call grprint(Format(rdoMiscImpr.Resultset("Total"), "###,###,###"), 8674, rover, 900, "L")
    rdoMiscImpr.Resultset.MoveNext
    tctr1 = tctr1 + 1
    Next zz
    End If

    On Error GoTo errhndlr

    Call grprint("Land Information", 240, 10740, 2000, "L")
    Call grprint("Valuation Totals", 5400, 10740, 2000, "L")
    Call grprint("Neighborhood", 240, 10940, 2000, "L")
    Call grprint("Lot Size", 240, 11120, 2000, "L")
    Call grprint("Land Value", 240, 11310, 2000, "L")
    Call grprint(rdoNbhdTable.Resultset("nbhd"), 1440, 10940, 2000, "R")
    ' this is all the stuff at the very bottom left of the report for commercial
    Call grprint(Format(rdoApprFile.Resultset("lotwidth"), "###,###,###"), 1440, 11120, 2000, "R")
    Call grprint(Format(rdoApprFile.Resultset("lotdepth"), "###,###,###"), 2000, 11120, 2000, "L")
    Call grprint(Format(rdoApprFile.Resultset("lotvalue"), "###,###,###"), 1440, 11300, 2000, "R")
    Call grprint(Format(rdoApprFile.Resultset("costval"), "###,###,###"), 7410, 10940, 2000, "L")
    Call grprint(Format(rdoApprFile.Resultset("incomeval"), "###,###,###"), 7410, 11120, 2000, "L")
    Call grprint(Format(rdoApprFile.Resultset("finestmt"), "###,###,###"), 7410, 11310, 2000, "L")
    Call grprint("X", 1800, 11120, 2000, "M")
    Call grprint("Cost Approach", 5301, 10940, 2000, "L")
    Call grprint("Income Approach", 5301, 11120, 2000, "L")
    Call grprint("Final Estimate Value", 5301, 11310, 2000, "L")
    CommandString = "rdoapprfile.resultset.(whatever field name)"
    End If

    End
    errhndlr:
    Call LogError(ErrDateTime, procname, ErrObj, FormObject, CommandString)
    End Sub

  2. #2
    Fanatic Member
    Join Date
    Aug 2000
    Posts
    617

    Hi

    There is some code here and so little time...

    I gave it a cursory look... And this just pure guess!!!

    Make sure you're not getting the error while the
    ON ERROR RESUME NEXT is in effect

    For quick testing, I'd remove all of them
    for now and let the

    "ON ERROR GOTO ERRORHANDLER" at the beginning of each proc
    and see if you're not trapping it...

    May be we'll take a closer look tomorrow


    Vale!

Posting Permissions

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



Click Here to Expand Forum to Full Width