Passing records between forms, validating and updating

SteveL

Member
Joined
Mar 14, 2006
Messages
6
Programming Experience
3-5
Hi
Please can someone offer me advice relating to the following scenario?

I am using a third party grid control bound to a table in SQL Server Express.

If a record is selected in the grid, a datarow is returned containing the record. At this point I instantiate a new form class that holds properties relating to the selected datarow. These are used to Display the record.

(This is where I get confused.)

1) How do I handle validation?

I am using an error provider control to validate mandatory fields in the 'ok' button click event. If the validation fails the form still closes. Do I have to cancel the button click event?
(If so, how? I tried 'Exit Sub') Or is there another approach?

2) How do I write changes back to the database and reflect those changes on the underlying selection grid?

Do I use stored procedures, or somehow reference the underlying grid to add rows?

Any help or samples would be greatly appreciated.

Thanks
 
Controls can raise thier own validation events. It is from there that a parameter in the event handler allows you to cancel an event based on criteria you specify. Check out on validation/on validating
 
Form Validation

Hi
The same dialog will be used for creating new records so the problem with that approach is the user has to enter/exit each control to fire the validation event.
S
 
The form close (me.close) should be inside the validation check, perhaps in the 'ELSE' clause of your validation. If No corrections are needed - data passes all your if statements - it falles into the 'ELSE' and the form closes
 
Back
Top