Moving between Tab Control subforms

I have a tab control on a form which has two pages. On each page there is a continuous subform (which can get quite long) and both subforms recordsource is the same table. What I would like to be able to do is scroll down the first subform and highlight a record using the record selector button and then click on the second tab. Now, I can then get it to goto the same record on the second tab, but the record goes to the top of the subform. I would like to keep the record in the same position as the one chosen on the first subform. Is this possible? And if so how?

Thanks in advance,

mcdermon
mcdermonAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

harfangCommented:
Everything is possible... some things are just a little bit harder :)

The properties available are scarce: .CurrentSectionTop indicates the distance between the active instance of the subform and the top of the form. This can provide the number of rows above the current selection. But there is no built-in method to scroll the window. Of course, you could find the WinAPI function for that...

Meanwhile, you can move the selection to force a scroll. That works only if there are records to select of course.

Toying with the idea, I came up with this. (Two subforms, both in datasheet view, same number of records, and a button to synchronize subform2 with subform1.)

Not ideal, but the best I could do without accessing the scroll bars.

--------------------------------------------------------------
Private Sub cmdSynch_Click()

    Dim frm1 As Form, frm2 As Form
    Dim intTest As Integer
   
    Set frm1 = subSynch1.Form
    Set frm2 = subSynch2.Form
   
    ' just looking nice while debugging
    frm1.SelLeft = 1: frm1.SelWidth = 10
   
    ' synchronize record numbers
    frm2.Recordset.AbsolutePosition = frm1.Recordset.AbsolutePosition
   
    ' try to scroll upwards
    For intTest = 1 To frm2.Recordset.AbsolutePosition
        If frm2.CurrentSectionTop >= frm1.CurrentSectionTop Then _
            Exit For
        With frm2.Recordset
            .AbsolutePosition = .AbsolutePosition - intTest
            .AbsolutePosition = .AbsolutePosition + intTest
        End With
    Next intTest
   
    ' try to scroll downwards
    For intTest = 1 To frm2.Recordset.RecordCount - frm1.SelTop
        If frm2.CurrentSectionTop <= frm1.CurrentSectionTop Then _
            Exit For
        With frm2.Recordset
            .AbsolutePosition = .AbsolutePosition + intTest
            .AbsolutePosition = .AbsolutePosition - intTest
        End With
    Next intTest
   
    ' just looking nice while debugging
    frm2.SelLeft = 1: frm2.SelWidth = 10
       
End Sub
--------------------------------------------------------------

Hope this helps!
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
mcdermonAuthor Commented:
Thank you so much! That works brilliantly even in continuous form view. And such a quick response. Fan-bleedin-tastic!!!

mcdermon
0
harfangCommented:
Well, I'm glad you like it :) cheers!
0
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Microsoft Access

From novice to tech pro — start learning today.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.