locked
Code not returing back accurate value. RRS feed

  • Question

  • I am attempting to understand why the below section of code is bringing in incorrect response.

                For Each row As DataRow In dt.Rows
                    If row("REC_DATE") IsNot DBNull.Value _
                            AndAlso row("LOADNUMBER") IsNot DBNull.Value _     ' <-- If REC_DATE & LOADEXPENSE are not NULL &     
                            AndAlso row("LOADNUMBER") > 0 _                    '     POSTLOAD cannot be 'Y" and the LOADNUMBER cannot be NULL or > '0'
                            AndAlso row("LOADEXPENSE") IsNot DBNull.Value _
                            AndAlso row("POSTLOAD") IsNot DBNull.Value _
                            AndAlso row("POSTLOAD") IsNot "Y" Then
    
                        LoadNumber = row("LOADNUMBER")
                        Dim loadrow As DataRow = dtLoad.Rows.Find(LoadDict(row("LOADNUMBER")))


    The issue is (I tried to attach an image for verification but my "Account has not been verified?" 

    My DT indeed has 'Y' (no quotes) in the POSTLOAD

    DEBUG sees the 'Y' yet calls:

    AndAlso row("POSTLOAD") IsNot DBNull.Value _ is seen as TRUE (this is correct as there is a value there)
    AndAlso row("POSTLOAD") IsNot "Y" as being TRUE (This is where the issue lies. The value is indeed 'Y' yet it says it is not.) 

    here is the actual DT I am working with:


    ID        DESCRIPTION           SECTION         REC_DATE                AMOUNT    POSTEXPENSE    POSTLOAD   POSTPERSONAL    EXPENSENAME         LOADEXPENSE    LOADNUMBER    PERSONALEXPENSE    DATE_ENTERED
    14989	TRIP REVENUE	        INCOME	        04/07/20 00:00:00	544.7400		 Y                          LINEHAUL_PAID        	       2020028	   04/07/20 00:00:00
    14990	FUEL SURCHARGE	        INCOME	        04/07/20 00:00:00	104.6100		 Y                          FUEL_SUR_PAID        	       2020028	   04/07/20 00:00:00
    14991	REEFER SURCHARGE	INCOME	        04/07/20 00:00:00	19.0200		         Y                          RFR_FUEL_SUR_PAID    	       2020028	   04/07/20 00:00:00
    14992	Broker / Factoring Fees	LOAD EXPENSES	04/07/20 00:00:00	20.0500	      Y	         Y                          BROKERAGE_FEE        	       2020028	   04/08/20 00:00:00
    

    • Edited by OgiKore Thursday, April 9, 2020 8:37 PM
    Thursday, April 9, 2020 8:22 PM

All replies

  • I would say, set in top of your code "Option Strict ON"

    The return value in the data fields are object, probably you have for instance to do

    AndAlso Cstr(row("POSTLOAD")) IsNot "Y" Then


    Success
    Cor

    Thursday, April 9, 2020 8:41 PM
  • I would a) follow Cor's recommendation for Option Strict On.

    Below highlighted code should read Row("ColumnName").Field(Of T)("ColumnName") so for Integer columns .Field(Of Integer) and string .Field(Of String) etc.


    Please remember to mark the replies as answers if they help and unmarked them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.

    NuGet BaseConnectionLibrary for database connections.

    StackOverFlow
    profile for Karen Payne on Stack Exchange

    Thursday, April 9, 2020 8:51 PM
  • Hi

    Why on earth should anyone bother to try and help you as you are likely to just abandon the thread after others have spent time and effort to answer your question. Just as you did with another THREAD!


    Regards Les, Livingston, Scotland


    • Edited by leshay Thursday, April 9, 2020 8:59 PM
    Thursday, April 9, 2020 8:59 PM
  • I have abandoned no thread.. not even sure what you are referring to? The other thread I am still working on the code issue and have other questions related to that but sorting this 'easier' issue first. DO NOT ASSUME something just because it has been 24 hours since I have responded.
    Thursday, April 9, 2020 9:06 PM
  • Added the OPTION STRICT ON

    This caused a lot of formatting issues that had to be resolved. Not a big issue and all are done.  Having put on Option Strict I am now being presented with 2 errors on the page I do not understand. I am not an advanced coder and this code was 'inherited' and I am trying to clean it up.

    ERROR 1:

                'Write to Expense Data
                For Each row As DataRow In dt.Rows
                    If row("REC_DATE") IsNot DBNull.Value _                                                ' <-- REC_DATE cannot be NULL 
                            AndAlso row("EXPENSENAME") IsNot DBNull.Value _                                ' <-- EXPENSENAME cannot be NULL
                            AndAlso CStr(row("POSTEXPENSE")) IsNot "Y" _                                   ' <-- POSTEXPENSE cannot be NULL or 'Y'
                            AndAlso row("POSTEXPENSE") Is DBNull.Value Then                                ' <-- POSTEXPENSE must be NULL
    
                        LoadNumber = 0 ' if "0" then error is on tbExpenses table side
                        ExpensesDataSet.Weekly_Expense_Table.Rows(0).Item(row("EXPENSENAME")) += row("AMOUNT")
                        Dim updaterow As DataRow = dttbExp.Rows.Find(row("ID"))
                        updaterow("POSTEXPENSE") = "Y"
                        dtrowExp += 1
                    End If
                Next
    The emboldened line error s with the following: "Visual Basic Overload resolution failed because no accessible 'Item' can be called with these arguments:"

    ERROR 2: Returning Option Strict On prohibits operands of type Object for operator '+'.   
    where emboldened

    For Each row As DataRow In dt.Rows
                    If row("REC_DATE") IsNot DBNull.Value _                                    ' <-- REC_DATE cannot be NULL
                            AndAlso row("LOADNUMBER") IsNot DBNull.Value _                     ' <-- LOADNUMBER cannot be NULL or > '0'     
                            AndAlso CInt(row("LOADNUMBER")) > 0 _                    '     
                            AndAlso row("LOADEXPENSE") IsNot DBNull.Value _                    ' <-- LOADEXPENSE cannot be NULL
                            AndAlso CStr(row("POSTLOAD")) IsNot "Y" _   ' <-- POSTLOAD _cannot_ be 'Y'
                            AndAlso row("POSTLOAD") Is DBNull.Value Then                       ' <-- POSTLOAD must be NULL
    
                        LoadNumber = CInt(row("LOADNUMBER"))
                        Dim loadrow As DataRow = dtLoad.Rows.Find(LoadDict(CInt(row("LOADNUMBER"))))
    
                        If CDec(row("LOADEXPENSE")) = CDec("LINEHAUL_PAID") Then
                            loadrow("DATE_PAID") = row("REC_DATE")
    
                            If Not loadsPD.Contains(CInt(loadrow("PETS_LOAD_NUMBER"))) Then
                                loadsPD.Add(CInt(loadrow("PETS_LOAD_NUMBER")))
                                strloadspaid = strloadspaid & (CInt(loadrow("PETS_LOAD_NUMBER"))) & ", "
                            End If
                        End If
    
                        loadrow(row("LOADEXPENSE").ToString) += row("AMOUNT")
    
                        Dim updaterow As DataRow = dttbExp.Rows.Find(row("ID"))
    
                        updaterow("POSTLOAD") = "Y"
                        dtrowLoad += 1
                    End If
                Next



    • Edited by OgiKore Thursday, April 9, 2020 10:08 PM corrected mis information
    Thursday, April 9, 2020 9:45 PM
  • Karen - In my attempt to use your idea I end up with a 'Option Strict On disallows Late Binding' error.
    Thursday, April 9, 2020 9:49 PM
  • Karen - In my attempt to use your idea I end up with a 'Option Strict On disallows Late Binding' error.

    Sorry been out, that is correct, Option Strict On requires early binding which produces faster and optimized code while without Option Strict On the runtime engine but determine types.

    I've maybe used Option Strict Off once in 20 years and that is a maybe.

    My rule of thumb is 

    Option Strict On

    Option Infer On


    Please remember to mark the replies as answers if they help and unmarked them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.

    NuGet BaseConnectionLibrary for database connections.

    StackOverFlow
    profile for Karen Payne on Stack Exchange

    Friday, April 10, 2020 12:55 AM
  • Hey, I appreciate the assist and understand one has different things going on in life. :)

    So in relation to my two errors above, surely it is something to do with the OPTION STRICT ON I added but I cannot determine what needs fixed.

    Could you provide some possible guidance with it?

    Friday, April 10, 2020 2:37 AM
  • Hey, I appreciate the assist and understand one has different things going on in life. :)

    So in relation to my two errors above, surely it is something to do with the OPTION STRICT ON I added but I cannot determine what needs fixed.

    Could you provide some possible guidance with it?

    Okay, if these are the problem.

    ExpensesDataSet.Weekly_Expense_Table.Rows(0).Item(row("EXPENSENAME")) += row("AMOUNT")

    loadrow(row("LOADEXPENSE").ToString) += row("AMOUNT")

    In both cases you are attempting to add a object and numeric values, with option strict off the runtime engine figures out what type the value in .Item is while with Option Strict on that is not possible so you need to strong type the operation e.g.

    in the following example I'm using a loosely type DataSet as I don't have your strong typed dataset with strong typed table name.

    Dim currentAmount = row.Field(Of Integer)("Amount")
    
    Dim expenseAmount = ds.Tables("Weekly_Expense_Table").
            Rows(0).Field(Of Integer)("EXPENSENAME")
    
    ds.Tables("Weekly_Expense_Table").
        Rows(0).SetField("EXPENSENAME",
                         expenseAmount + currentAmount)
    


    Please remember to mark the replies as answers if they help and unmarked them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.

    NuGet BaseConnectionLibrary for database connections.

    StackOverFlow
    profile for Karen Payne on Stack Exchange

    Friday, April 10, 2020 10:29 AM
  • This one never goes

    Loadrow(row("LOADEXPENSE").ToString) += row("AMOUNT")

    Probably something as this will go 

    Loadrow(CDec(row("LOADEXPENSE")) += Cdec(row("AMOUNT"))

    Has a chance to go (with the correct value type)

    https://docs.microsoft.com/en-us/dotnet/visual-basic/language-reference/functions/type-conversion-functions

    Without late binding you never can add to a string and with late binding it is the same as going to Vegas and setting all your money on one value. 


    Success
    Cor



    Friday, April 10, 2020 12:48 PM
  • Line 435: Error    BC30518    Overload resolution failed because no accessible 'Item' can be called with these arguments:
        'Public Overloads Default Property Item(columnIndex As Integer) As Object': Option Strict On disallows implicit conversions from 'Object' to 'Integer'.
        'Public Overloads Default Property Item(columnName As String) As Object': Option Strict On disallows implicit conversions from 'Object' to 'String'.
        'Public Overloads Default Property Item(column As DataColumn) As Object': Option Strict On disallows implicit conversions from 'Object' to 'DataColumn'.

    This is the full error I am getting on the line:

                        ExpensesDataSet.Weekly_Expense_Table.Rows(0) _
                            .Item(row("EXPENSENAME")) += row("AMOUNT")

    Sorry I am not real understanding of late binding and it's effects.

    Friday, April 10, 2020 3:41 PM
  • I tried that already Cor. This did not resolve the issue unfortunately.
    Friday, April 10, 2020 3:42 PM
  • Line 435: Error    BC30518    Overload resolution failed because no accessible 'Item' can be called with these arguments:
        'Public Overloads Default Property Item(columnIndex As Integer) As Object': Option Strict On disallows implicit conversions from 'Object' to 'Integer'.
        'Public Overloads Default Property Item(columnName As String) As Object': Option Strict On disallows implicit conversions from 'Object' to 'String'.
        'Public Overloads Default Property Item(column As DataColumn) As Object': Option Strict On disallows implicit conversions from 'Object' to 'DataColumn'.

    This is the full error I am getting on the line:

                        ExpensesDataSet.Weekly_Expense_Table.Rows(0) _
                            .Item(row("EXPENSENAME")) += row("AMOUNT")

    Sorry I am not real understanding of late binding and it's effects.

    That code is BAD code and late binding is BAD practice. I never use late binding only strong typing of variables and data, well I have no choice for the most part when working in web apps e.g. JavaScript or Cold Fusion, ASP.NET in some cases.

    Please remember to mark the replies as answers if they help and unmarked them if they provide no help, this will help others who are looking for solutions to the same or similar problem. Contact via my Twitter (Karen Payne) or Facebook (Karen Payne) via my MSDN profile but will not answer coding question on either.

    NuGet BaseConnectionLibrary for database connections.

    StackOverFlow
    profile for Karen Payne on Stack Exchange

    Friday, April 10, 2020 4:12 PM
  • Oh yea but that is not from the code you first gave us, it seems to come from somewhere in outerspace. 

    ExpensesDataSet.Weekly_Expense_Table.Rows(0).Item(row("EXPENSENAME")) += row("AMOUNT")

    It looks like a part from an strongly typed dataset (a dataset created with a designer)

    With that a class is created to give your dataset strong typed names. It is hidden but if you do in solution explorer Show All files you probably see that code. 

    Problem is, we cannot see if it is a class or an object, because both are created as code. If you are using this you should strongly rely on the intelisense names which are given when coding.

    If you use such a strongly typed dataset, then don't use code which is not from a strongly dataset it seems to go right, but at a certain moment it goes wrong.

    Somehow you should be able to say something as

    For each row as ExpenseRow in ExpensedDataset.Weekly_Expense_Table 

    And then something as 

    row.ExpenseName += Row.Amount

    By the way, do yo like those underscores which the office team of Microsoft ones made best practise (in their team)?


    Success
    Cor




    Friday, April 10, 2020 4:58 PM
  • Somehow you should be able to say something as

    For each row as ExpenseRow in ExpensedDataset.Weekly_Expense_Table 

    And then something as 

    row.ExpenseName += Row.Amount

    By the way, do yo like those underscores which the office team of Microsoft ones made best practise (in their team)?





    In response to the first comment:

    For Each row As DataRow In dt.Rows is the head piece of this section. I'm assuming this meets the criteria you refer to above. I did include that in the 2nd piece of this freakin puzzle.

    Would it be more helpful if I submitted the entire SUB code? It is fairly lengthy (almost 200 lines). But I think for someone way up the chain in knowledge from me it would help diagnose this faster.

    Please understand, this is inherited code and I am trying to 'fix' issues. This is beyond my understanding so thus why I come here to try and resolve and learn what/how to fix.

    In relation to your second question about the 'underscores': I can take it or leave it. I prefer one continuous line as opposed to the breaking of it, unless, of course, it is either a very long line or is doing multiple things.


    • Edited by OgiKore Friday, April 10, 2020 7:36 PM
    Friday, April 10, 2020 7:30 PM
  • As response to your last question.

    1. Make a decision. My favorite in that. Do it with Strongly Typed code.
    2.  If you use underscores, that is up to you, but it is more difficult for those to help you because it is not anymore used.

    But please don't give us a kind of code which is half based on strongly typed an the other half lousely typed . We are helping you for free. If you need professional paid help, than buy it. They can come along, we see only what you show us. And as Les already wrote, it does not help as you start more times with code which is not understandable for us.  

    It is up to you to make those decisions, not to us. 


    Success
    Cor

    Friday, April 10, 2020 7:51 PM
  • In the hope that this clears up everything here is the entire section of code I'm trying to repair.

    Is it best code practices, I cannot fully say.

        Private Sub BtnImportExpenses_Click(sender As Object, e As EventArgs) Handles btnImportExp.Click
            WeekDict.Clear()
    
            Dim wrkdate As Date = CDate(dtpEntryDate.Value.ToShortDateString)
            Dim wrkdate1 As Date
    
            wrkdate1 = wrkdate.AddDays(-6)
    
            Dim taSecDesc As New tbExpensesDatasetTableAdapters.tbEXPENSESTableAdapter
            Dim dt As New DataTable
            LoadForm = True
            ExpensesDataSet.Weekly_Expense_Table.Clear()
            ExpensesDataSet.Clear()
    
            LoadForm = False
    
            'Weekly Expense Data Table
            Dim taExp As New ExpenseDataSetTableAdapters.Weekly_Expense_TableTableAdapter
            taExp.Adapter.SelectCommand = New SqlCommand("Select * 
                                                            FROM Weekly_Expense_Table 
                                                           WHERE PAYROLL_DATE = '" & wrkdate.ToShortDateString & "'", taExp.Connection)
    
            taExp.Adapter.Fill(ExpensesDataSet.Weekly_Expense_Table)
    
            If ExpensesDataSet.Weekly_Expense_Table.Rows.Count = 0 Then
                If MsgBox("No Weekly Expense records found!", MsgBoxStyle.OkCancel) = MsgBoxResult.Cancel Then Return
                SetDefaults()
    
                Dim nr As DataRow = ExpensesDataSet.Weekly_Expense_Table.NewRow
                nr("ID") = -1
                nr("PAYROLL_DATE") = wrkdate.ToShortDateString
                ExpensesDataSet.Weekly_Expense_Table.Rows.Add(nr)
                WeekDict.Add(wrkdate, ExpensesDataSet.Weekly_Expense_Table.Rows.Count - 1)
            End If
    
            'Dim init As Boolean
            'init = True
    
            'Load Info Table
            Dim dtLoad As New LoadInfoDataSet.Load_Info_TableDataTable
            Dim taLoad As New LoadInfoDataSetTableAdapters.Load_Info_TableTableAdapter
            taLoad.Adapter.SelectCommand = New SqlCommand("SELECT * FROM Load_Info_Table ORDER BY ID", taLoad.Connection)
    
            taLoad.Adapter.Fill(dtLoad)
            Dim LoadDict As New Dictionary(Of Integer, Integer)
            For Each row As DataRow In dtLoad.Rows
                LoadDict.Add(CInt(row("PETS_LOAD_NUMBER")), CInt(row("ID"))) 'An import error here may mean a Load Number has already been used or input wrong. Check & correct for incorrect Load Number.
            Next
    
            Dim begdate As String = wrkdate1.ToShortDateString
            Dim enddate As String = wrkdate.ToShortDateString
            taSecDesc.Adapter.SelectCommand = New SqlCommand("SELECT tbEXPENSES.ID, DESCRIPTION, SECTIONS, REC_DATE, AMOUNT, POSTEXPENSE, POSTLOAD, POSTPERSONAL, EXPENSENAME, LOADEXPENSE, LOADNUMBER, PERSONALEXPENSE, DATE_ENTERED FROM tbDESCRIPT" &
                         " LEFT OUTER JOIN tbSECTIONS ON tbDESCRIPT.SECT_ID = tbSECTIONS.ID" &
                         " LEFT OUTER JOIN tbEXPENSES ON tbDESCRIPT.ID = tbEXPENSES.DESCRIPT_ID And tbEXPENSES.REC_DATE Between '" & begdate & "' and '" & enddate & " 23:59:59'" &
                         " WHERE REC_DATE IS NOT NULL ORDER BY tbSECTIONS.ID, tbDESCRIPT.ID, LOADNUMBER", taSecDesc.Connection)
    
            Dim dttbExp As New tbExpensesDataset.tbEXPENSESDataTable
            Dim tatbExp As New tbExpensesDatasetTableAdapters.tbEXPENSESTableAdapter
    
            tatbExp.Adapter.SelectCommand = New SqlCommand("SELECT * FROM tbExpenses WHERE REC_DATE Between '" & begdate & "' and '" & enddate & " 23:59:59'", tatbExp.Connection)
            tatbExp.Adapter.Fill(dttbExp)
    '
            'Dim dtcolname = tbExpensesDataset.tbEXPENSESDataTable.ColumnName'
            Dim dtrowExp As Integer = 0
            Dim dtrowLoad As Integer = 0
            Dim LoadNumber As Integer = 0
            Dim ds As New DataSet
    
            Dim loadsPD As New List(Of Integer)
            Dim strloadspaid As String = ""
            If Not ExpensesDataSet.Weekly_Expense_Table.Rows(0).Item("LOADS_PAID").ToString = "" Then
                strloadspaid = ExpensesDataSet.Weekly_Expense_Table.Rows(0).Item("LOADS_PAID").ToString & ", "
            End If
    
            Try
                Cursor = Cursors.WaitCursor
                taSecDesc.Adapter.Fill(dt)
    
                'Write to Expense Data
                For Each row As DataRow In dt.Rows
                    ' All conditions are true, then write the line, otherwise it is a duplicate and do not write line.
                    If CStr(row("REC_DATE")) IsNot DBNull.Value _                       ' <-- REC_DATE cannot be NULL 
                            AndAlso row("EXPENSENAME") IsNot DBNull.Value _             ' <-- EXPENSENAME cannot be NULL
                            AndAlso row.Field(Of String)("POSTEXPENSE") IsNot "Y" _     ' <-- POSTEXPENSE cannot be 'Y'
                            AndAlso row("POSTEXPENSE") Is DBNull.Value Then             ' <-- POSTEXPENSE must be NULL
    
                        LoadNumber = 0 ' if "0" then error is on tbExpenses table side
                        ExpensesDataSet.Weekly_Expense_Table.Rows(0) _
                            .Item(row("EXPENSENAME")) += row("AMOUNT")
    
                        Dim updaterow As DataRow = dttbExp.Rows.Find(row("ID"))
                        updaterow("POSTEXPENSE") = "Y"
                        dtrowExp += 1
                    End If
                Next
    
                'Write to Load Info
                For Each row As DataRow In dt.Rows
                    ' All conditions are true, then write the line, otherwise it is a duplicate and do not write line.
                    If row("REC_DATE") IsNot DBNull.Value _                             ' <-- REC_DATE cannot be NULL
                            AndAlso row("LOADNUMBER") IsNot DBNull.Value _              ' <-- LOADNUMBER cannot be NULL or > '0'     
                            AndAlso row.Field(Of Integer)("LOADNUMBER") > 0 _           '     
                            AndAlso row("LOADEXPENSE") IsNot DBNull.Value _             ' <-- LOADEXPENSE cannot be NULL
                            AndAlso row.Field(Of String)("POSTLOAD") IsNot "Y" _        ' <-- POSTLOAD cannot be 'Y'
                            AndAlso row("POSTLOAD") Is DBNull.Value Then                ' <-- POSTLOAD must be NULL
    
                        LoadNumber = CInt(row("LOADNUMBER"))
                        Dim loadrow As DataRow = dtLoad.Rows.Find(LoadDict(row.Field(Of Integer)("LOADNUMBER")))
    
                        If row.Field(Of Decimal)("LOADEXPENSE") = row.Field(Of Decimal)("LINEHAUL_PAID") Then
                            loadrow("DATE_PAID") = row("REC_DATE")
    
                            If Not loadsPD.Contains(CInt(loadrow("PETS_LOAD_NUMBER"))) Then
                                loadsPD.Add(CInt(loadrow("PETS_LOAD_NUMBER")))
                                strloadspaid = strloadspaid & (CInt(loadrow("PETS_LOAD_NUMBER"))) & ", "
                            End If
                        End If
    
                        Dim currentAmount = row.Field(Of Integer)("Amount")
                        Dim expenseAmount = ds.Tables("Weekly_Expense_Table").Rows(0).Field(Of Integer)("EXPENSENAME")
    
                        ds.Tables("Weekly_Expense_Table").Rows(0).SetField("EXPENSENAME", expenseAmount + currentAmount)
    
                        '                    loadrow(CDec(row("LOADEXPENSE"))) += CDec(row("AMOUNT"))
    
                        Dim updaterow As DataRow = dttbExp.Rows.Find(row(row.Field(Of Integer)("ID")))
    
                        updaterow("POSTLOAD") = "Y"
                        dtrowLoad += 1
                    End If
                Next
    
                dt.AcceptChanges()
                If strloadspaid.Contains(","c) Then
                    Dim lastcommaindex As Integer = strloadspaid.LastIndexOf(","c)
                    If strloadspaid.Length = lastcommaindex + 2 Then
                        ExpensesDataSet.Weekly_Expense_Table.Rows(0).Item("LOADS_PAID") = strloadspaid.Remove(strloadspaid.LastIndexOf(","c), 1)
                    End If
                End If
                Dim index As Integer = 0
                For Each row As DataRow In ExpensesDataSet.Weekly_Expense_Table.Rows
                    row("PAGE_TOTAL") = CDec(row("ACCOUNTANT_FEES")) + CDec(row("BROKERAGE_FEE")) + CDec(row("BUSINESS_INCOME_TAX")) + CDec(row("CDL_RENEWALS")) _
                        + CDec(row("CLOTHING_EXPENSE")) + CDec(row("COST_OF_ITEM")) + CDec(row("DOT_PHYSICAL")) + CDec(row("DRUG_CONSORTIUM")) + CDec(row("EQUIPMENT_WASHING")) _
                        + CDec(row("EZPASS_FEE")) + CDec(row("FED_EMP_INCOME_TAX")) + CDec(row("FED_HEAVY_USE")) + CDec(row("FED_PAYROLL_TAX")) + CDec(row("FUEL_CARD_CHARGE")) _
                        + CDec(row("IFTA_FEES")) + CDec(row("KY_ROAD_USE")) + CDec(row("MEDICARE_TAX")) + CDec(row("NM_ROAD_USE")) + CDec(row("NY_ROAD_USE")) + CDec(row("PAYROLL_FEES")) _
                        + CDec(row("PAYROLL_SOFTWARE")) + CDec(row("PAYROLL_TOTAL")) + CDec(row("PB_ADJUSTMENT")) + CDec(row("PERMIT_PURCHASE")) + CDec(row("PIKE_PASS_FEE")) _
                        + CDec(row("PRE_PASS_FEE")) + CDec(row("PU_DRP_TRLR_FEE")) + CDec(row("PURCHASE_TAX_PAID")) + CDec(row("QC_RENTAL")) + CDec(row("RAND_MCNALLY")) _
                        + CDec(row("SOCIAL_SECURITY_TAX")) + CDec(row("STATE_PAYROLL_TAX")) + CDec(row("SUN_PASS_FEE")) + CDec(row("TAX_AMOUNT_PAID")) + CDec(row("TN_ANNUAL_REPORT")) _
                        + CDec(row("TN_FRANCHISE_TAX")) + CDec(row("TN_INCOME_TAX")) + CDec(row("TRANSACTION_FEE")) + CDec(row("TRAILER_INSPECTION")) + CDec(row("TRAILER_OTHER")) _
                        + CDec(row("TRAILER_PAYMENT")) + CDec(row("TRANSFLO_FEE")) + CDec(row("TRAVEL_EXPENSE")) + CDec(row("TRUCK_INSPECTION")) + CDec(row("TRUCK_INSURANCE")) _
                        + CDec(row("TRUCK_PAYMENTS")) + CDec(row("TRUCK_REGISTRATION")) + CDec(row("TRUCK_WASHING")) + CDec(row("UCR_YEARLY"))
                Next
    
                'Clean up
                taExp.Adapter.Update(ExpensesDataSet.Weekly_Expense_Table)
                tatbExp.Adapter.Update(dttbExp)
                taLoad.Adapter.Update(dtLoad)
                LoadForm = True
                ExpensesDataSet.Weekly_Expense_Table.Clear()
                LoadExpenses()
                ExpensesDataSet.AcceptChanges()
                dtLoad.Dispose()
                taLoad.Dispose()
                Cursor = Cursors.Default
    
                'This message shows if an import is incorrect: See Weekly_Expense_Table
            Catch ex As Exception
                MessageBox.Show(ex.ToString & vbCrLf & vbCrLf & ex.Message & vbCrLf & vbCrLf & "CHECK THE WEEKLY_EXPENSE_TABLE OR LOAD_INFO_TABLE FOR INCORRECT LOAD NUMBER OR THE LOAD NUMBER CANNOT BE FOUND." & vbCrLf & vbCrLf & "Expense Row Number: " & dtrowExp.ToString & vbCrLf & "Load Row Number: " & dtrowLoad.ToString & vbCrLf & "Load Number: " & LoadNumber.ToString)
            End Try
            dtpEntryDate.Value = wrkdate
    
        End Sub



    • Edited by OgiKore Friday, April 10, 2020 8:26 PM
    Friday, April 10, 2020 8:24 PM