Q:

Function returns true, but then it becomes false upon assignment

I call a function (SaveChanges) to access my business / data layer and save any changes to fields that are marked as an Add or Update and are marked to be processed. This function used to work fine up until 60+ minutes ago.
What is happening is that suddenly the function is returning false. After debugging through the code, when it hits Return the local boolean is set as True ... but when it gets back to the calling method (and uses the return value) it is now False.
As I said I went through line by line and debugged it, then I added a watch to it. The funny part is that there is one spot that sets the boolean to false, and when I put a breakpoint on that spot it is never reached.
Here is the function:
Private Function SaveChanges() As Boolean

    Dim blnSaved As Boolean = True

    Dim saveableRows As List(Of DataRow) = (From d As DataRow In _listData.Tables(0).Rows _
                                            Where Not d("Marking") = "Duplicate" _
                                            And d("Process") = True _
                                            Select d).ToList()

    If saveableRows.Count > 0 Then

        For Each drRow As DataRow In saveableRows

            Dim data As IDataEntity = DataEntities.GetData(_tableName)

            If drRow("Marking") = "Update" Then

                'UPDATE
                data.UpdateItem(drRow.ItemArray)

            Else

                'ADD
                data.AddItem(drRow.ItemArray)

            End If

            If data.HasErrors Then

                blnSaved = False 'Never reaches this part ... !?!?!

            End If

        Next

    Else

        blnSaved = True

    End If

End Function

And here is how I'm using the function:
If SaveChanges() Then

        Dim frmTableView As frmTableView = New frmTableView(_listData.Tables(0).TableName)

        If Not Me.MdiParent Is Nothing Then

            frmTableView.MdiParent = Me.MdiParent

        End If

        frmTableView.Show()

        Me.Close()

    Else

        MessageBox.Show("Unable to save the list. IT has been notified.", "Save Failed", MessageBoxButtons.OK, MessageBoxIcon.Error)

    End If

I'm spending too much time on this and figured it was time to look for help.
Thanks

A:

You're never returning your boolean. Add:
Return blnSaved

at the bottom of the function.

