G
Guest
Hi everyone
I have subform within a main form and want the last-entered data to be
displayed on the subform when the main form is entered or a different record
is displayed. I have the following code:
Private Sub Form_Current()
MySubForm.SetFocus
On Error Resume Next
DoCmd.GoToRecord , , acLast
On Error GoTo 0
code continues ...
Everything works fine when the main form is opened. However, if I scroll
through the records by using the record selector at the bottom of the form,
the records displayed on the main form change correctly, but the data on the
subform is that which was entered first, rather than last, even if I return
to the first record on the main form which was displayed when the form was
opened initially.
I suspect it's because this code is in the wrong event. I've tried several
locations, including Form On Change, Form On Got Focus, Form On Activate but
I can't get it to work correctly. Am I on the right track of having the code
in the wrong event (which is the correct one?) or is the problem likely to be
something else?
Thanks for your time.
I have subform within a main form and want the last-entered data to be
displayed on the subform when the main form is entered or a different record
is displayed. I have the following code:
Private Sub Form_Current()
MySubForm.SetFocus
On Error Resume Next
DoCmd.GoToRecord , , acLast
On Error GoTo 0
code continues ...
Everything works fine when the main form is opened. However, if I scroll
through the records by using the record selector at the bottom of the form,
the records displayed on the main form change correctly, but the data on the
subform is that which was entered first, rather than last, even if I return
to the first record on the main form which was displayed when the form was
opened initially.
I suspect it's because this code is in the wrong event. I've tried several
locations, including Form On Change, Form On Got Focus, Form On Activate but
I can't get it to work correctly. Am I on the right track of having the code
in the wrong event (which is the correct one?) or is the problem likely to be
something else?
Thanks for your time.