Master/Detail Databinding issue

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



Dear group,

I have an invoice entry form, which is a simple Master fields / Detail grid.
The main summary information of the invoice are stored in one table in a
dataset, which is bound using a BindingSource (InvoiceBindingSource). The
line details of each item in the invoice is held in a child table which is
bound to another bindingsource (InvoiceRowsBindingSource).

I took the basic design from an MSDN article, and all works well. However...

When I come to save the record
(taInvoiceRows.update(Dataset.InvoiceRowsTable)), sometimes I get a message
similar to: "You cannot save this table, because a row is required in
Invoice [the master table].

I know the problem is most likely related to the way I'm saving:

Save subroutine:

' Save master binding source (invoice)
InvoiceBindingSource.EndEdit()
' Save detail binding source (invoice rows)
InvoiceInvoiceRowsBindingSource.EndEdit()

' Call tableadapter update for master table
bInvoiceSaved = _taInvoice.Update(DsInvoice1.Invoice)

' Call tableadapter update for row table *******OCCASIONAL RANDOM CRASH
HERE***********
bInvoiceRowSaved = _taInvoiceRow.Update(DsInvoice1.InvoiceRows)


I also call .EndEdit for the master bindingsource whenever any of the master
fields lose focus. I also call .EndEdit for the detail bindingsource
whenever any row of the grid loses focus.

My first question is:

1) How should I handle this error? (row not present in the master table when
updating the child table)
2) What's the correct way to do this? (save a Master/Detail form?)

The error is apparantly random, I don't yet have steps to reproduce it
accurately every time. Other than this, the form works fine. Both the master
and detail grid have other lookup comboboxes representing other fields, all
working ok. The dataset was created in the DataSet Designer, and the
database is a Microsoft Access MDB (so I'm using Jet for connectivity).

I'm stuck, but can't find any guidance on the "right way" to do a
Master/Detail form. I'm obviously not doing the right things, in the right
events. Please help!

Many thanks,

.



Relevant Pages

  • Re: Sequential Numbering from Blank Document (k)
    ... I understood that from a master file (as an example, Invoice Master), you ... > Private Sub Workbook_Open ... Sub SequentialNumber() ...
    (microsoft.public.mac.office.excel)
  • Re: In-Memory Dataset
    ... - User clicks Create New Invoice ... - Detail foreign key is temporarily set to -1 (same as master ... I have to post master dataset BEFORE posting detail ... which should UpdateBatch everything at ...
    (borland.public.delphi.database.ado)
  • Re: Unable to locate rows for updating
    ... >I have a master detail invoice form where the user selects the customer, ... ADO needs to be able to find the record in your database to delete. ... Your choices are adCriteriaKey, adCriteriaAllCols, ...
    (borland.public.delphi.database.ado)
  • Unable to locate rows for updating
    ... I have a master detail invoice form where the user selects the customer, ... before allowing inserts of the details info I post the master ... so the detail can have the invoice number and set a bookmark on the ...
    (borland.public.delphi.database.ado)
  • Re: DataGridViews, Master-Detail, Data-entry *and* Display
    ... I haven't figured out how to get the detail grid to ... display *only* the related records for the selected row in the master ... when a row in the master grid is clicked. ...
    (microsoft.public.dotnet.languages.vb)