简体   繁体   中英

MS Access: Prevent validation of subform

I am struggling with inadvertent triggering of validation rules when activating a subform.

In MS Access, I have a form with data about a patient, which contains a subform with one record of a medical device that belongs to this patient. The patients table has an [ID] field, and the medical devices table has a [PatientID] field. The medical devices table has a one-to-many relation with the patients table (one patient can have many medical devices).

When the form containing the subform is opened, the subform's Form_Load() method fills in certain fields such as the current date.

The problem is: As soon as any control of the subform is activated (via tabbing or clicking), the medical devices table's validation rules are triggered -- once and only once. After dismissing the validation error message, I can switch between the controls on the parent form and the subform without problem.

When I remove the code from the Form_Load() method, I can activate the subform's controls without triggering validation.

Both the parent form and the subform are linked to tables, not queries.

How can I fill in data in the subform using VBA without triggering validation?

I suggest you use default values, not actual text. Default values only become "real" when some other field is completed.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM