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 strongm on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Record saves when subform is clicked 1

Status
Not open for further replies.

load3d

Programmer
Feb 27, 2008
117
US
I have a form with 3 subforms. One is for data entry and the other two are continuous forms displaying queried data. On my data entry form when a new record is created and data is being entered, if the user clicks on one of the sub forms by accident or whatever, it saves the record. This is causing data issues for me. I have a save button that does error checking but it doesn't do the error checking if the subform is clicked. I've tried putting some error checking in the Before Update field like "If me.field isnull then cancel -1". I've also tried moving the code from my save button to the Before Update on the form, no luck. I know of a few other things to try but what is the BEST way to handle this problem?
 
What do you mean by disabling the form? How would you do that?


 

This is normal behavior; a record on main form is saved when moving to a subform and a record on a subform is saved when to the main form. Having a "Save" button frequently leads to problems if data validation is needed, and is really unnecessary; Accesss automatically saves a record when the user moves to another record or closes the form.

Validation to assure that a given control or controls are populated should go in the Form_BeforeUpdate event. Prompting the user as to whether they want to save a given record or not should also go here.

Validation for a given field that involves assuring that the data conforms to certain rules probably should go in the BeforeUpdate event for that given control. This includes, for instance, such things as checking to make sure that a date is in the future, making sure that an amount entered is in even dollars, or making sure that a serial number is X number of digits long. By having this kind of Validation in the control's BeforeUpdate event, if the data doesn't conform with your criteria, the user is notified as soon as the data is entered and the focus will remain in field.

The Missinglinq

Richmond, Virginia

There's ALWAYS more than one way to skin a cat!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top