scrolling a form with an interactive script

W

wgoldfarb

I am writing an Access application that takes the user through a script. The
interview is dynamic, so each answer determines what the subsequent questions
will be. Thus, the text (in the form of labels) and controls for upcoming
questions remain hidden and are only displayed when they are needed in the
script (code in each control's 'lost focus' event determines which question
should be next depending on previous results. The code then displays the
appropriate control by adjusting its vertical position, setting its visible
property to 'true' and giving it the focus).

The script is somewhat long, so the form where the script is contained is
much higher than the window that contains it. Thus, as the user progresses in
the script he/she needs to manually scroll down to be able to access the new
questions that are being displayed. I am trying to have the window scroll
automatically, so that each time the script reaches the bottom of the screen,
the form will automatically scroll up and the next question will appear at
the top of the screen.

My problem is that I cannot scroll the form with any degree of precision. I
have tried the following 4 calls to the Windows API:

lngRet = SendMessage(Me.hWnd, WM_VSCROLL, SB_LINEDOWN, 0&)
(calling it more than once, to scroll several lines)

lngRet = SendMessage(Me.hWnd, WM_VSCROLL, SB_PAGEDOWN, 0&)

lngRet = SendMessage(Me.hWnd, EM_LINESCROLL, 0, Lines&)
(where Lines& specifies the number of lines to scroll)

and even

intRet = SetScrollPos(Me.hWnd, SBS_VERT, intLines, True)

none of these seem to allow me to position the control with any accuracy at
the top of the window: they either scroll too much, or not nearly enough. In
the last case (SetScrollPos) the result is always the same regardless of the
number of lines I specify! what am I doign wrong? Is there any way to scroll
the window more precisely?

Thanks,

William
 
J

Jesper

The script is somewhat long, so the form where the script is contained is
much higher than the window that contains it. Thus, as the user progresses
in
the script he/she needs to manually scroll down to be able to access the
new
questions that are being displayed. I am trying to have the window scroll
automatically, so that each time the script reaches the bottom of the
screen,
the form will automatically scroll up and the next question will appear at
the top of the screen.

My problem is that I cannot scroll the form with any degree of precision.
I
have tried the following 4 calls to the Windows API:

lngRet = SendMessage(Me.hWnd, WM_VSCROLL, SB_LINEDOWN, 0&)
(calling it more than once, to scroll several lines)

lngRet = SendMessage(Me.hWnd, WM_VSCROLL, SB_PAGEDOWN, 0&)

lngRet = SendMessage(Me.hWnd, EM_LINESCROLL, 0, Lines&)
(where Lines& specifies the number of lines to scroll)

and even

intRet = SetScrollPos(Me.hWnd, SBS_VERT, intLines, True)

I've been looking for a way to scroll in a long form but I don't any way to
manipulate the scrollbars.
Would you mind revealing how you make the above code work? What is the
SendMessage function?
I could really use this.

Thanks .

Jesper
 
T

Tim Ferguson

I am writing an Access application that takes the user through a
script. The interview is dynamic, so each answer determines what the
subsequent questions will be.

This sounds like a Wizard. There are lots of examples of how to code these
-- I think there are some in Northwind and in the advanced macro library.

The clue is to use the PageBreak controls rather than scroll bars.

Hope that helps


Tim F
 
T

Tim Ferguson

What is the 'advanced macro library'?

It's one of the utility MDAs that come with Access. I hardly ever install
it these days, but you could check your install options.

HTH


Tim F
 
W

wgoldfarb

Tim,

Thanks! After messing around with all those API calls, your suggestion ended
up being very easy: I used PageBreak controls in conjunction with the
GoToPage method, and it worked perfectly. Thanks!
 

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