Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Using separate form to add child records

Status
Not open for further replies.

sillysod

Technical User
Jan 6, 2004
300
GB
Lets say I have a Master/Detail form bound to Linq2Sql objects (for arguments sake an Order / Order Line form)

The order form shows the order lines in a datagrid, which is readonly

To add/edit an order line the user clicks a button.

The button opens up another form and the details are entered and when the user clicks save the record is added.

AI could pass an order line object to the form and show it modal,if the user clicks save the form returns true

Pseudo Code :

Code:
NewLineButton_Click
   dim OLine as new OrderLine
   dim f as frmOrderLine

   If f.AddOrderLine(OLine) = true Then
       Order.OrderLines.Add(OLine)
   End if
End Sub

However I would like the form to not be modal, in which case I cant do the
Order.OrderLines.Add(OLine)
part on the parent form as i dont know whether the user clicked save or cancel.

I tried passing the Order.OrderLines collection ByRef to the child and doing the Add there, however I loose the ByRef when i store the collection in a variable to use when the Save button is clicked.


Does anyone have any suggestions how to handle adding items to a collection on a parent form, without using Modal child forms?


Cheers,
Daniel


 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top