Results 1 to 11 of 11
  1. #1
    5 Star Lounger
    Join Date
    May 2001
    Location
    Patterson Lakes, Melbourne, Victoria, Australia
    Posts
    636
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Can anyone advise me how to sc (How to scroll a from from code?)

    Can anyone advise me how to scroll a form using code?
    I have subforms on an unbound main form. I cannot for the life of me find how to scroll the main form from code.
    In desperation I tried SendKeys. But no mater how well I took focus from a subform and put it on the main form, SendKeys "{PGDN}", True, still paged down on the subform instead of the main form. I even went as far as writing to a control on the main form before the SendKeys, no dice. There MUST be a way to scroll a form.
    Help!
    Regards,
    Peter

  2. #2
    3 Star Lounger
    Join Date
    Jan 2001
    Location
    Brisbane, Queensland, Australia
    Posts
    352
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Can anyone advise me how to sc (How to scroll a from from code?)

    Would setting the focus to a control on the next part of the form do it? If your form has distinct screen areas, you could set the focus to the first control in each area.

    But I don't know why you would want to!
    David Grugeon
    Brisbane Australia

  3. #3
    Silver Lounger
    Join Date
    Jan 2001
    Location
    Indianapolis, Indiana, USA
    Posts
    1,862
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Can anyone advise me how to sc (How to scroll a from from code?)

    I'm sorry that I don't have a more definite answer for you, but API is one way to go. It used to scare me, but with the help of some websites and some free software from <A target="_blank" HREF=http://www.allapi.net/>All API Net</A> I've successfully used quite a few AIP functions.

    Another idea is to use the GoToPage method of the form...Check the Access Helpfiles for details on that.

    I'll try to come up with something more solid to give you in the mean time.

    HTH <img src=/S/salute.gif border=0 alt=salute width=15 height=20>

  4. #4
    5 Star Lounger
    Join Date
    May 2001
    Location
    Patterson Lakes, Melbourne, Victoria, Australia
    Posts
    636
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Can anyone advise me how to sc (How to scroll a from from code?)

    Thanks for your reply. Good to hear from a fellow Aussie.
    The reason why, is that the main form contains 5 subforms, that are larger than the main form. Going to a record on any sub form frequently puts the active control below the bottom of the main form. The user can physically scroll down, but it would be much easier to automatically go there.
    Since the post, I have managed to get the end result I am aiming for, but I have to go through all these SendKeys. Some of these SendKeys undo previous ones, but if I omit any of them, the subform scrolls out of sight above the top of the main form.
    I only got this to work because of your suggestion to put a control on another part of the main form (Detail section)
    This is weird in the extreme.

    SchedFrm.SetFocus
    Forms![frmScheduling]![txtFocusRcvDetail].SetFocus
    SendKeys "{PGUP 3}", True 'Moves to top of SchedForm
    SendKeys "{PGDN " & Pg & "}", True
    SchedFrm("sub" & WkFrm.Name).SetFocus
    SendKeys "{PGUP " & Pg & "}", True
    SchedFrm.SetFocus
    Forms![frmScheduling]![txtFocusRcvDetail].SetFocus
    SendKeys "{PGDN " & Pg & "}", True

    Regards Peter Kinross Melbourne
    Regards,
    Peter

  5. #5
    5 Star Lounger
    Join Date
    May 2001
    Location
    Patterson Lakes, Melbourne, Victoria, Australia
    Posts
    636
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Can anyone advise me how to sc (How to scroll a from from code?)

    Thanks Mark.
    I can't use the GoToPage, there are no pages on the main form. I tried that AllAPINet, but couldn't find anything there. Would rather avoid it if possible.
    I still find it hard to believe that there isn't a standard way to scroll a form from code. Ah well.
    If you do think of anything please let me know.
    Regards,
    Peter

  6. #6
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Can anyone advise me how to sc (How to scroll a from from code?)

    You can insert page breaks into the main form. That will allow you to use GoToPage. As for scrolling a form from code, how would you determine how far to scroll it? And what are you scrolling, a continuous form, a form too big for the screen, a form with distinct sections, or what? You can see that it isn't quite as simple as just "scrolling" a form.
    Charlotte

  7. #7
    5 Star Lounger
    Join Date
    May 2001
    Location
    Patterson Lakes, Melbourne, Victoria, Australia
    Posts
    636
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Can anyone advise me how to sc (How to scroll a from from code?)

    Putting page breaks on the main form works.
    to answer your question; I can tell how far to page down by using the .AbsolutePosition property of the subform
    Regards,
    Peter

  8. #8
    Silver Lounger
    Join Date
    Jan 2001
    Location
    Indianapolis, Indiana, USA
    Posts
    1,862
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Can anyone advise me how to sc (How to scroll a from from code?)

    Subforms - now you're talking! I've been in a similar situation in the past. I used a trick, much like Grugeon's suggestion. I placed a textboxe BEHIND each of the subforms. When the user clicked a button to jump to a certain position, I set focus to the "hidden" text box, then immediately set focus to the desired subform. This worked very well to move the position of the window to the desired location. It took a little work to get the positions right, but I finally got it.

    I realize you may already have a solution that works, but I'm going to try to find the API function for this as well - this may be something others can use in the future (including myself).

    HTH <img src=/S/salute.gif border=0 alt=salute width=15 height=20>

  9. #9
    Plutonium Lounger
    Join Date
    Dec 2000
    Location
    Sacramento, California, USA
    Posts
    16,775
    Thanks
    0
    Thanked 1 Time in 1 Post

    Re: Can anyone advise me how to sc (How to scroll a from from code?)

    Ah, so you're talking continuous subforms here, right? I hadn't realized that. But why are you "scrolling" at all. If you move the subform's bookmark to the record you want, it will have the same effect.
    Charlotte

  10. #10
    5 Star Lounger
    Join Date
    May 2001
    Location
    Patterson Lakes, Melbourne, Victoria, Australia
    Posts
    636
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Can anyone advise me how to sc (How to scroll a from from code?)

    There are 5 parallel subforms (1 for each week of the month). Scrolling one subfrom scrolls it alone up above the top of the main form. I am looking at scrolling all subforms, then scrolling the main form so that the subform record is near the top of the main form.
    Well in an ideal world, that
    Regards,
    Peter

  11. #11
    5 Star Lounger
    Join Date
    May 2001
    Location
    Patterson Lakes, Melbourne, Victoria, Australia
    Posts
    636
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Re: Can anyone advise me how to sc (How to scroll a from from code?)

    Yeah, I
    Regards,
    Peter

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •