Move subform with horizontal scroll bar

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • reginaldmerritt
    New Member
    • Nov 2006
    • 201

    Move subform with horizontal scroll bar

    Hi

    I use a subform on a mainform as a type of menu selection. I want to keep the subform in the middle of the screen when the mainform horizontal scroll bar is moved.

    Is there an event on the horizontal scroll bar I can use?

    What method is used to move a subform on a main form?

    Thanks
  • twinnyfo
    Recognized Expert Moderator Specialist
    • Nov 2011
    • 3662

    #2
    reginaldmerritt ,

    One possible sollution, would be to actually make your main form a subform on another form. Then place your original subform on that new master form as well. The original master form, now a subform, could scroll to the left or right in its own right, and the original subform, now a subform on a different master form, would be stationary.

    You would have to tweak all the master/child relationships for data to make sure that all the forms were linked together, but it might be the easiest way to solve, rather than trying to code figuring out exactly how far a form has moved, then moving the subform.

    Let me know if you make any headway on this....

    Comment

    • reginaldmerritt
      New Member
      • Nov 2006
      • 201

      #3
      Thanks twinnyfo that's a good suggestion.

      The main form is a continuous multi record form. If I make the mainform a subform the vertical scroll bar would be set within the subform; and this doesn't display well when viewing the database on a workstation with a large display. but nice suggestion though, thanks.

      Comment

      • twinnyfo
        Recognized Expert Moderator Specialist
        • Nov 2011
        • 3662

        #4
        I don't know what type of data you have, that requires such a wide record view.... Is there a reason you couldn't put one entire record in a view? Even if you made a reasonably wide, tall view for the entire record, it might help. But, based on your description, I understand your desire to be able to move that subform.

        Still thinking about this one.........

        Comment

        • reginaldmerritt
          New Member
          • Nov 2006
          • 201

          #5
          I managed to create a public subroutine to move any control. You use it in the following manner

          Call MoveControl(amo unt to move left, amount to move top, amount to move width, amount to move height,name of control)

          In my case i just want to move the subform left acording to the user scrolling.

          Code:
          Call MoveControl(40,0,0,0,"MenuSubform")
          Code:
          Public Sub MoveControl(lngLeft As Long, lngTop As Long, lngWidth As Long, lngHeight As Long, ContolName As String)
          Dim lngCL, lngCT, lngCW, lngCH As Long
          
          lngCL = Controls(ContolName).Left
          lngCT = Controls(ContolName).top
          lngCW = Controls(ContolName).width
          lngCH = Controls(ContolName).height
          
          With Controls(ContolName)
              Call .Move(lngCL + lngLeft, lngCT + lngTop, lngCW + lngWidth, lngCH + lngHeight)
          End With
          End Sub

          Comment

          • reginaldmerritt
            New Member
            • Nov 2006
            • 201

            #6
            Problem is I still haven't found a property that changes as the user scrolls. If anyone has any ideas they would be very much appreciated.

            Many Thanks

            Comment

            • twinnyfo
              Recognized Expert Moderator Specialist
              • Nov 2011
              • 3662

              #7
              Innovative solution. But, just out of curiosity, how do you know how far to move the particular control?, especially since it is related to a scroll bar. Is there a way to gauge what percentage the scroll bar has travelled?

              This migh thave some useful applications--especially in situations like yours......

              Comment

              • reginaldmerritt
                New Member
                • Nov 2006
                • 201

                #8
                I can not identify how much the scroll bar has moved as I can not find property that relates to this.

                Comment

                • reginaldmerritt
                  New Member
                  • Nov 2006
                  • 201

                  #9
                  Shame that there isn't an OnScroll event or a property that changes when the scroll bar is moved. Would be great if there was a property that showed how much the scroll bar has moved or the scroll bar current location.

                  Perhaps there is a way of moving a control to a certain pixel location. Perhaps doing this on a timer event would be a good work around this.

                  However, I've decided to fix this issue in another way. Rereading what 'twinnyfo' put in a previous post I decided to display the data differently by putting the records on another subform. This way the scrolling would only effect the subform and not the main form or the other subform I was having issues with.

                  So haven't actually solved the problem of moving a subform or any control based on the scroll bar but this fix will be sufficient for now. If anyone does have a way of moving controls based on scroll bar position I would be very much interested.

                  twinnyfo thanks for your help with this.

                  Comment

                  • twinnyfo
                    Recognized Expert Moderator Specialist
                    • Nov 2011
                    • 3662

                    #10
                    Reginald,

                    I have been trying to track down this scrollbar thing, too. Apparently there IS a stand-alone scrollbar object in Access (somewhere) and MS provides all this information all over the place about how to gather data from it........ But nowhere does it tell us how to put this control on our forms!

                    Oh, well. I'm glad I could provide a plausible, if not desired, option for your form. If I track this scrollbar thing down, I will repost....

                    Comment

                    • twinnyfo
                      Recognized Expert Moderator Specialist
                      • Nov 2011
                      • 3662

                      #11
                      MS Excel..... but not for Access apparently...

                      I guess you could "make" a scrollbar in your form, that would just move a small box along a continuum using scroll buttons.....

                      Comment

                      • zmbd
                        Recognized Expert Moderator Expert
                        • Mar 2012
                        • 5501

                        #12
                        "stand-alone scrollbar object in Access"
                        Poor choice of names by MS for this control. It is also found in Excel as a "form control" that you can place on a worksheet… as to why it’s not directly available in Access… once again the genius of Microsoft.

                        This is NOT a windows Scroll-bar.

                        This is a slider type control along the same lines as the spinner-buttons (think slider volume control or dimmer switch etc.) http://msdn.microsoft.com/en-us/libr.../gg278467.aspx

                        To get this control on an access form… insert an active-x
                        [imgnothumb]http://bytes.com/attachments/attachment/6536d1344461417/slidercontrol.j pg[/imgnothumb]

                        - This control is only vertical from what I can tell...
                        - Getting the events to fire for it within Access is a hit and miss. Works great in excel; however, I prefer the spinner buttons... which brings us to:
                        - There are a lot easier controls for users to use.

                        And... there you go.

                        -z
                        Attached Files

                        Comment

                        • twinnyfo
                          Recognized Expert Moderator Specialist
                          • Nov 2011
                          • 3662

                          #13
                          Thanks, z! I knew there had to be some way to use it....

                          Comment

                          • reginaldmerritt
                            New Member
                            • Nov 2006
                            • 201

                            #14
                            Thanks, I knew there had to be some Activex control, i'm sure there has to be a horizontal control out there somewhere too.

                            Comment

                            • twinnyfo
                              Recognized Expert Moderator Specialist
                              • Nov 2011
                              • 3662

                              #15
                              Reginald,

                              Just resize the control so that it is wider than it is tall and it becomes a horizontal scrollbar.....

                              Comment

                              Working...