Using my example app on my desktop PC both values are 330.
The code is stable whether I use 4, 6 or nothing
On my tablet PC, the values are 336 and 340!
Despite that, its also currently stable using 4, 6 or nothing.
I assume the variation in those two values is related to resolution and/or screen size.
Probably safest to do a check for those values on form load and allow for the actual difference in the code
For example:
@orangeCode:Option Compare Database Option Explicit Dim intCST As Integer, intSHH As Integer, intDiff As Integer Private Sub Detail_Paint() 'modified to allow for twips difference in currentsectiontop compared to header height If Me.CurrentSectionTop > Me.Section(acHeader).Height + intDiff Then Me.TimerInterval = 0 Me.Recordset.Bookmark = Me.Bookmark Me.Recordset.Move -Round((Me.CurrentSectionTop - Me.Section(acHeader).Height - intDiff) / Me.Section(acDetail).Height) Me.TimerInterval = 100 End If End Sub Private Sub Form_Load() intCST = Me.CurrentSectionTop intSHH = Me.Section(acHeader).Height intDiff = intCST - intSHH End Sub Private Sub Form_Timer() Me.TimerInterval = 0 Parent.fsubImageTooltip.Requery End Sub Private Sub Form_Open(Cancel As Integer) If Application.CurrentObjectName = Me.Name Then MsgBox "This form is designed to be used with other forms. " & vbCrLf & vbCrLf & _ "It cannot be opened directly from the navigation pane ", vbExclamation, "Action not allowed!" Cancel = True Exit Sub End If End Sub
Does this now work for you?
Yes, that sounds good. It didn't occur to me that the current record would necessarily be the top one, because I was forgetting that the getting-out-of-sync behaviour I'd discovered occurred only in Form_Paint. What you've proposed is better than my other idea of allowing margins of 10 twips (say) either way.
@Colin,
RE, v1.62
Yes it works now without the uncontrolled scrolling. I am able to use the vertical scroll and the down arrow at bottom of vertical scroll.
Interesting, can not upload a gif. Gets converted to static jpg???
Hi Jack
Many thanks. Hopefully we now have code that will work on all workstations.
If not, the next step might need to be to use the Wizhook.TwipsFromFont function to identify / use the exact heights in code as in my Web article Accurately Move Forms & Controls (isladogs.co.uk)
Out of interest, what were the two values you got for currentsectiontop and section(acHeader).Height?
FYI I had similar problems with uploading video GIFs a few days ago
Colin:
?Me.CurrentSectionTop
336
?Me.Section(acHeader).Height
330
Also, notified Admin re gifs.
Come to think of it, we've overcomplicated it slightly. This would do:
Code:If Me.CurrentSectionTop > intCST Then Me.TimerInterval = 0 Me.Recordset.Bookmark = Me.Bookmark Me.Recordset.Move -Round(Me.CurrentSectionTop - intCST) / Me.Section(acDetail).Height) Me.TimerInterval = 100 End If
For info, I've just added an article based on this topic to my website: Continuous subform selection using the vertical scrollbar
Thanks again to @Remster for coming up with the ideas developed in this thread.
Last edited by isladogs; 07-16-2022 at 02:06 PM.