Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations gkittelson on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Access 2000. Can I force the Active Window to scroll to the top?

Status
Not open for further replies.

dkaplan

Programmer
Jan 29, 2001
98
US
I have a subform on a tab control which is larger than the active window. When users click this tab, Access naturally scrolls to the bottom of the subform, thus causing needed details on the master form to scroll out of view. Is there some way I can force the master form to the top of the active window?

I’ve tried imbedding a PAGEUP via sendkey in the click event of the page. This works, but there’s a hitch. Not all users have the same resolution. In cases where the main form has *not* scrolled out of view, the PAGEUP moves the form to the previous record.

Thanks in advance.

Dennis
 
You could put a tiny, unbound text box at the top of the main form, setting its background to transparent and its border to none. It should be invisible, and if the box is very short, the cursor will barely show. Make sure it's in the tab page's tab order ahead of the subform control.

It would be better, of course, to make the form fit the screen. There are two ways to do that: Resizing the form (which involves resizing and possibly moving its controls--fairly complex) and using alternative forms for different resolutions. If you'd like code that can determine the resolution of the current screen, I'll dig it out for you. Rick Sprague
 
Thanks, Rick.

And, yes, if you have it handy, it would be nice to be able detect the current screen resolution.

Dennis
 
Here you go:
Code:
Code
Public Const SM_CXSCREEN = 0
Public Const SM_CYSCREEN = 1
Public Declare Function GetSystemMetrics Lib "user32" Alias "GetSystemMetrics" (ByVal nIndex As Long) As Long

'==================================================
' ScreenRes - Return the current screen resolution
'==================================================
Function ScreenRes() As String
'Purpose: Return a string giving the current screen resolution
'Returns: A string of the form ""NNNxNNN"", e.g. ""640x480"" or ""1024x768""
    Dim horz As Long, vert As Long
    
    horz = GetSystemMetrics(SM_CXSCREEN)
    vert = GetSystemMetrics(SM_CYSCREEN)
    ScreenRes = CStr(horz) & ""x"" & CStr(vert)
End Function
Rick Sprague
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top