I have a table in my dataset which is used to locally store and process a set of records for use with a form. The table is LocalInfoTables.TREEpartsTreed. I have a function running to update the data in that table based on a query tied to a SQL server. The function runs down one row at a time and changes the rows if the query finds related data. This is done by using a loop starting with:
A dataset is created with the information to be used for the update, and then fields in the databale are updated based on the dataset. Below is the list of field changes as they occur:
This works fine for all fields except the last one, which should set LIgen. When the code executes, this line is highlighted and I get the error "Object reference not set to an instance of an object."
I've verified that the field does exist in the datable being updated, the name is correctly typed both places. If I comment out that line, the code fires without error, so the d_Hist("Remain") reference is not the issue, since it's used on the line before this one to set r("Remain"). I tried deleting and resetting the line to make sure I didn't have any typos, and I refreshed the dataset. But it does not appear to see this field. Can anyone suggest a possible fix?
Cheryl dc Kern
Code:
For Each r As DataRow In LocalInfoTables.TREEpartsTreed.Rows
Code:
d_Hist = dtHist.Rows(0)
r("AmtRun") = d_Hist("HowMany")
r("LastUnit") = d_Hist("LastUnit")
r("LIqty") = d_Hist("SNofUnits")
r("Remain") = d_Hist("Remain")
r("LIgen") = d_Hist("Remain")
I've verified that the field does exist in the datable being updated, the name is correctly typed both places. If I comment out that line, the code fires without error, so the d_Hist("Remain") reference is not the issue, since it's used on the line before this one to set r("Remain"). I tried deleting and resetting the line to make sure I didn't have any typos, and I refreshed the dataset. But it does not appear to see this field. Can anyone suggest a possible fix?
Cheryl dc Kern