P
Paul James
I have a main form that contains a subform. When this form opens, there are
a number of records in the underlying recordset, but there are no records in
the subform. That is, none of the records in the main form have any
corresponding records in the subform. The purpose of this form is to create
those corresponding records in the subform.
I've removed the form's usual navigation buttons, and replaced them with
some custom navigation labels in the main form, so I can run my validation
checks before the user can either navigate to a new record (in the main
form) or close the form. If those conditions are not met, a message box
appears explaining the problem and requiring the user to either fix the
problem, or delete the record in the subform.
Everything works fine as long as the main form has the focus when the user
clicks on one of the navigation controls. In that case, the new record is
displayed in the main form, and the subform has no record. The problem
occurs when one of the subform controls has the focus, and the user clicks
on a navigation button. This is a problem because when the main form moves
to the new record, the record in the subform is what Access calls "dirty."
And if the user then tries to move to another record without making any
conscious entry in the subform, it violates the validation rules.
I've tried a number of things to overcome this, like returning the focus to
a control in the main form in the Mouse Down event of the navigation
control, thinking that if I get OUT of the subform before the main form
moves to the next record, surely the subform record won't be changed. But
no such luck.
I've also tried deleting the "dirty" record in the subform when no values
have been entered, but I get a message saying there's no record to delete.
I also tried using SendKeys {esc}{esc} to clear the subform, but that didn't
have any effect either.
Does anyone have any suggestions about how to deal with this probem that
occurs when you don't want to create empty records in the subform as the
user moves to another record in the main form when a control in the subform
has the focus?
Thanks in advance,
Paul
a number of records in the underlying recordset, but there are no records in
the subform. That is, none of the records in the main form have any
corresponding records in the subform. The purpose of this form is to create
those corresponding records in the subform.
I've removed the form's usual navigation buttons, and replaced them with
some custom navigation labels in the main form, so I can run my validation
checks before the user can either navigate to a new record (in the main
form) or close the form. If those conditions are not met, a message box
appears explaining the problem and requiring the user to either fix the
problem, or delete the record in the subform.
Everything works fine as long as the main form has the focus when the user
clicks on one of the navigation controls. In that case, the new record is
displayed in the main form, and the subform has no record. The problem
occurs when one of the subform controls has the focus, and the user clicks
on a navigation button. This is a problem because when the main form moves
to the new record, the record in the subform is what Access calls "dirty."
And if the user then tries to move to another record without making any
conscious entry in the subform, it violates the validation rules.
I've tried a number of things to overcome this, like returning the focus to
a control in the main form in the Mouse Down event of the navigation
control, thinking that if I get OUT of the subform before the main form
moves to the next record, surely the subform record won't be changed. But
no such luck.
I've also tried deleting the "dirty" record in the subform when no values
have been entered, but I get a message saying there's no record to delete.
I also tried using SendKeys {esc}{esc} to clear the subform, but that didn't
have any effect either.
Does anyone have any suggestions about how to deal with this probem that
occurs when you don't want to create empty records in the subform as the
user moves to another record in the main form when a control in the subform
has the focus?
Thanks in advance,
Paul