By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
435,492 Members | 3,174 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 435,492 IT Pros & Developers. It's quick & easy.

Master/Detail Databinding issue

P: n/a
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)
' Save detail binding source (invoice rows)

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

' Call tableadapter update for row table *******OCCASIONAL RANDOM CRASH
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,

May 6 '07 #1
Share this question for a faster answer!
Share on Google+

This discussion thread is closed

Replies have been disabled for this discussion.