By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
426,107 Members | 1,323 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 426,107 IT Pros & Developers. It's quick & easy.

Move subform with horizontal scroll bar

reginaldmerritt
100+
P: 201
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
Jul 30 '12 #1
Share this Question
Share on Google+
18 Replies


twinnyfo
Expert Mod 2.5K+
P: 3,210
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....
Jul 30 '12 #2

reginaldmerritt
100+
P: 201
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.
Jul 30 '12 #3

twinnyfo
Expert Mod 2.5K+
P: 3,210
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.........
Jul 30 '12 #4

reginaldmerritt
100+
P: 201
I managed to create a public subroutine to move any control. You use it in the following manner

Call MoveControl(amount 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.

Expand|Select|Wrap|Line Numbers
  1. Call MoveControl(40,0,0,0,"MenuSubform")
Expand|Select|Wrap|Line Numbers
  1. Public Sub MoveControl(lngLeft As Long, lngTop As Long, lngWidth As Long, lngHeight As Long, ContolName As String)
  2. Dim lngCL, lngCT, lngCW, lngCH As Long
  3.  
  4. lngCL = Controls(ContolName).Left
  5. lngCT = Controls(ContolName).top
  6. lngCW = Controls(ContolName).width
  7. lngCH = Controls(ContolName).height
  8.  
  9. With Controls(ContolName)
  10.     Call .Move(lngCL + lngLeft, lngCT + lngTop, lngCW + lngWidth, lngCH + lngHeight)
  11. End With
  12. End Sub
  13.  
  14.  
Aug 8 '12 #5

reginaldmerritt
100+
P: 201
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
Aug 8 '12 #6

twinnyfo
Expert Mod 2.5K+
P: 3,210
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......
Aug 8 '12 #7

reginaldmerritt
100+
P: 201
I can not identify how much the scroll bar has moved as I can not find property that relates to this.
Aug 8 '12 #8

reginaldmerritt
100+
P: 201
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.
Aug 8 '12 #9

twinnyfo
Expert Mod 2.5K+
P: 3,210
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....
Aug 8 '12 #10

twinnyfo
Expert Mod 2.5K+
P: 3,210
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.....
Aug 8 '12 #11

zmbd
Expert Mod 5K+
P: 5,397
"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



- 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 Images
File Type: jpg slidercontrol.jpg (70.6 KB, 2721 views)
Aug 8 '12 #12

twinnyfo
Expert Mod 2.5K+
P: 3,210
Thanks, z! I knew there had to be some way to use it....
Aug 8 '12 #13

reginaldmerritt
100+
P: 201
Thanks, I knew there had to be some Activex control, i'm sure there has to be a horizontal control out there somewhere too.
Aug 9 '12 #14

twinnyfo
Expert Mod 2.5K+
P: 3,210
Reginald,

Just resize the control so that it is wider than it is tall and it becomes a horizontal scrollbar.....
Aug 9 '12 #15

zmbd
Expert Mod 5K+
P: 5,397
the one I've shown doesn't work that way... it only goes top to bottom... making wider only makes the button wider.

there is no horizontal standalone that I can find.

unless there is a windows api call there's not much more to add.

-z
Aug 9 '12 #16

twinnyfo
Expert Mod 2.5K+
P: 3,210
I'm using Access 2007, same ActiveX Control.....
Attached Images
File Type: jpg Scrollbar.jpg (77.7 KB, 519 views)
Aug 9 '12 #17

zmbd
Expert Mod 5K+
P: 5,397
Very interesting...
when I tried it, that did not happen... the control simply became wider!
I'll have to give it w whirl again and see if I can get it to do the same thing!
-z
Aug 9 '12 #18

zmbd
Expert Mod 5K+
P: 5,397
Well...
Worked on my Office-PC just as twinnyfo suggested.
I would then think that one could use the on-enter/got-focus events to pull the control's current value. Depending on the complexity of the form you might then use the Updateevent to do a smooth scoll using the idea by reginaldmerritt in post #5 or use the on-exit/lost-focus event to get the control's updated value to do a final "snap" to...

-z
(now why didn't that work at home? same program, same revision level... Look, that rabbit's got a vicious streak a mile wide! It's a killer! )
Aug 9 '12 #19

Post your reply

Sign in to post your reply or Sign up for a free account.