Subforms stay on first record

R

RGBrighton

I have a a couple of sub-subforms on a subform . (' sub2s' on 'sub1')
Each sub2 only has 2 or 3 linked records but when I place the cursor on any
record in the sub2 (eg to edit or start a new sub record) it skips back to
the first record in its list. Both sub2s behave like this. Neither sub2
(nor their parent sub1) has any event code. The main form has lots of code.

The sub2s have record selectors which I hope to use to delete records - if
only the focus would stay on the record!

About a month ago they worked fine but I have been working on other bits of
the database since then. I imported the equivalent sub2 from an earlier (OK)
version and it still misbehaves in the current database.

Sorry there is not much to go on.
(a) Any suggestions where I might start looking?
(b) Is there any debugging technique to allow me to see which events have
recently fired in order to try and track down whatever is causing the current
sub2 form to go back to the first record all the time?

Thanks
Richard
 
M

Marshall Barton

RGBrighton said:
I have a a couple of sub-subforms on a subform . (' sub2s' on 'sub1')
Each sub2 only has 2 or 3 linked records but when I place the cursor on any
record in the sub2 (eg to edit or start a new sub record) it skips back to
the first record in its list. Both sub2s behave like this. Neither sub2
(nor their parent sub1) has any event code. The main form has lots of code.

The sub2s have record selectors which I hope to use to delete records - if
only the focus would stay on the record!

About a month ago they worked fine but I have been working on other bits of
the database since then. I imported the equivalent sub2 from an earlier (OK)
version and it still misbehaves in the current database.

Sorry there is not much to go on.
(a) Any suggestions where I might start looking?
(b) Is there any debugging technique to allow me to see which events have
recently fired in order to try and track down whatever is causing the current
sub2 form to go back to the first record all the time?


Check the main form's amd sub1's code for something that is
manipulating the sub2s (e.g. Requery)
 
M

Maurice

Sounds like code from your mainform is performing a requery on the subform at
a certain event. Requery will set the cursorposition back to the first
record. So start by takng a look at the events triggered in regards to your
subform.
 
R

RGBrighton

Thanks Maurice - I appreciate your help and I recognise I have not given much
to go on!

I have searched code in the main form and there are no requeries. There is
a procedure that reselects the records by changing the SQL in the
recordsource (of the main form) to reflect some filtering controls. I have
tried 'commenting out' the relevant lines of code but am still unable to get
the focus to remain on any but the first record in either sub2 form.

Is there any way I can see/track what events have been triggered? (I am not
that familiar with the debugging systems available!)

Thanks
Richard
 
M

Marshall Barton

RGBrighton said:
I have searched code in the main form and there are no requeries. There is
a procedure that reselects the records by changing the SQL in the
recordsource (of the main form) to reflect some filtering controls. I have
tried 'commenting out' the relevant lines of code but am still unable to get
the focus to remain on any but the first record in either sub2 form.

Is there any way I can see/track what events have been triggered? (I am not
that familiar with the debugging systems available!)


(Re)setting the RecordSource is a heavy duty Requery so that
explains the original problem.

You can add:
Debug.Print "some identifying text"
statements to the top of each event procedure to see which
ones and in what order they are triggered.

If you'll post a copy/paste of the suspect procedure(s?) we
can take a look to see if anything jumps out. I do have to
wonder how/why that procedure executes when the user is
working in a subform??
 
J

John W. Vinson

There is
a procedure that reselects the records by changing the SQL in the
recordsource (of the main form) to reflect some filtering controls.

That will requery the form.
 
R

RGBrighton

Hi Marshall,
I appreciate your interest.
I have put in the debug statements and the change recordsource is not being
triggered yet the insistence on staying at first record persists. I am
getting to think the problem is linked to some recordsource SQL in one of the
sub1 fields.

I am going to examine the older version where the problem seems to be absent
and see if I can spot any significant difference.

I feel I should offer more detail - but it seems so complex to describe.
Perhaps that is indicatative of my problem - I think I need to do some
serious documenting!

Thank you for your help
Richard
 
R

RGBrighton

Thanks John, but debug statements indicate that code is not triggering.
Richard
 
M

Marshall Barton

RGBrighton said:
I have put in the debug statements and the change recordsource is not being
triggered yet the insistence on staying at first record persists. I am
getting to think the problem is linked to some recordsource SQL in one of the
sub1 fields.

I am going to examine the older version where the problem seems to be absent
and see if I can spot any significant difference.


Both of those are good ideas. Keep in mind that Requery and
changing the RecordSource are not the only ways to create
the problem. Unlikely are those other ways may be, keep your
eyes open for any code you do not fully understand.
 
R

RGBrighton

Thanks for your sugggestions Marshall, All support through this forum is
much appreciated.
Haven't had time today to get stuck into tracing through the modules...and I
am away now for about two weeks so I apologise if this thread goes dead then
comes back to life again!!

Regards
Richard
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top