I have an order form open, where the grid is used for adding order lines to the order.
When opening an order that has been created, then adding a new line to it, I'm then opening another form, for adding some of the other details to the order line (I'm not closing the main form, just opening a new one).
However, when the new form opens, the initial data that was saved with the report is removed from the grid, and only the newly added, unsaved data is then shown.
What could be causing this?
The code for opening the new form:
Try For Each ugr As UltraGridRow In ugProducts.Rows If IsDBNull(ugr.Cells("Supplier_Code").Value) = True Then MsgBox("Please select a supplier for all products first", MsgBoxStyle.OkOnly, "Select a Supplier") Exit Sub End If Next
Dim dt As New DataTable dt = ugProducts.DataSource
Dim f As New frmFreight(con, dt, Me, cmbCustCode.Text, orderNumber) f.MdiParent = Me.MdiParent f.Show()
Catch ex As Exception errorLog(ex)
End Try
Sorry, I meant the data that is saved with the order, not the report... That was me in Crystal Reports mode, I've been working with that for the last 2 weeks, my bad!
Anyway, the issue was that I was manipulating the datatable directly from the new form, rather than creating a copy and editing that one.
Hi David,
I am not entirely following issue entirely. You have your Order Form, that opens an Order Detail Form, when you want to add a new detail line on the Order Form. You are adding new data, so I am guessing the Order Detail Form is mostly empty to begin with, but your Order Form likely has some initial information, and perhaps other detail lines.
Here's where you lose me a bit, when the new form opens: I am assuming the Order Detail Form, the initial data that was saved with the report? Do you mean the other information on the Order Form is cleared from the Order Form, when the Order Detail Form opens? What is the report, is that a different object or are you referring to the Order Form? Newly added, unsaved data, I am assuming you mean the data that was filled into the Order Detail Form, when filled out and closed, populates the Order Form, but the previous Order Form detail lines are wiped out?My guess is the issue is on your Order Detail Form. There is nothing in your snippet that would cause the issue directly. Just that it identifies that you are passing in references to the DataSource of the Order Form grid, the Order Form itself, and whatever con is. I would likely need a sample application to better understand what is going on. But I would follow those three variables on your Order Detail Form, and see what you are doing with them. Are you re-instantiating dt? Are you calling Clear before you add? Are you accessing sub properties on your form that is passed in? If so what are you modifying.
Hope this helps,