Q on weird subform skip behaviour

T

Terrell Miller

Help, I'm getting strange results on a subform and I'm wondering if
anybody knows what is causing it...

I have a form linked to TableA. On that form is a tab control. Page1 is
just the controls for TableA, except for the caseID (PK) which is above
the tab control.

Then on Page2 of the tab I have a linked subform that's bound (via
caseID so it's a one-to-one relationship due to number of fields) to
TableB, and so on for Page3.

What's happening is that on FormB and FormC there are a bunch of option
groups interspersed with text boxes. Tab order is set correctly. For the
first few option groups on Page3 (FormC) everything works fine, when I
use the tab key to navigate through there's no problem.

But when I get to the second section of the form, which is not visible
when you first click on the page (it's a long form), every time I _Enter
one of the checkboxes in that section the focus moves to teh correct
control, but on the display it takes me up to the very top of the
subform, so the control I just entered is not visible anymore.

That has apparently only been happening for the last few days, the
client says she hasn't seen this before, she could tab through the
controls all the way to the bottom of the form.

Couple other potential factors: each section has a huge label
surrounding it. I did the SendToBack with no effect, adn there are no
handlers on the labels.

Each of the option groups (the ones that work fine *and* the ones that
get screwy results) have identical _Enter and _Exit handlers that change
the background color of the control to mimic the conditional formatting
"HasFocus" that you can do with a text box or combo box. I checked the
code, and these are working fine and have not changed.

Added a _OnDirty handler to see if maybe a control up near the top was
getting changed, but that handler never fires.

When you click on either Page2 or Page3 you are moving to a subform so
we have some _BeforeUpdate and _AfterUpdate handlers for the main Form A
that will insert a new record into FormB/C. That's been there, though,
and no changes to the subroutine for awhile.

When I open FormC as a standalone this doesn't happen, I can tab through
the controls with no problems. Thinking Ther ewas a corruption issue I
tried copying FormC and renaming, no luck. I tried opening a blank form
and copying the entire contents of FormA, still no luck.

I searched the KB but didn't find anything using several different
search phrases (not sure what to call this).

Has anybody seen a similar phenomenon? What causes it?

One possible workaround occurred to me, on the checkboxes we could add
code to somehow capture the scrollbar position inside the subform and
scroll back to the location of the ActiveControl. Or, we could grab the
"coordinates" of the ACtiveControl and then scroll to them after the
subform has done its mischief. Sort of a kludge either way and I'd
rather eliminate the problem entirely, but I'm willing to add that in if
necessary. Is it possible to grab the scrollbar location of a (sub)form
and then programmatically reset the scrollbar position to that value
later with VBA code?

Or do you know of a slicker solution?

Thanks for your help and for reading through this epic!


--
Terrell Miller
(e-mail address removed)

"Every gardener knows nature's random cruelty"
-Paul Simon RE: George Harrison
 
J

Jamey

Sounds as if you are refreshing your data for your subform on the
Subform_Enter event or something along those lines. Any kind of update
to the data in the table the subform is based on will produce similar
results. Sometimes with updates or with any sort of SQL that is running
as the result of an event followed by a refresh or requery command
(more likely the requery) you'll see erratic behavior for which record
gets the focus when you go back into the subform. If there is any kind
of SetFocus command in the subform, you may also get undesired results.
I'd start by looking for a requery command somewhere in the code.
 

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