Reputation: 1960
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?
Upvotes: 0
Views: 262
Reputation: 91356
I suggest you use default values, not actual text. Default values only become "real" when some other field is completed.
Upvotes: 1