Question : Form Dirty Values Lost on Forms 2.0 Scrollbar Methods :(

I have an unbound form that is using a VBA timer event to periodically update the position of an unbound scrollbar.

There's just one annoying problem with this.  Every time the timer fires, it deletes any dirty value being edited in a text box field at the time.

For example:  In an empty text box I type in "abc".  The timer fires and updates the position of the scroll bar slider.  Now when I tab out of that text box, the text will disappear rather than saving the input.

If I type in "abc" and then quickly hit the tab key, then the text is saved as expected.

In the past I had tried to work around this by calling saverecord at the very top of the timer function, however doing so blocked the application long enough to be even more annoying than the original problem.

I need a way to update this scrollbar without losing input and without messing around with the focus or using slow, blocking functions.

Answer : Form Dirty Values Lost on Forms 2.0 Scrollbar Methods :(

I think I've got it.  It feels sloppy, but it's working!
1:
2:
3:
4:
5:
6:
7:
8:
9:
10:
11:
12:
13:
14:
15:
16:
17:
18:
19:
    Dim ctlCurrentControl As Control
    Dim frmCurrentForm As Form
    Dim lSelStart As Long
    Dim lSelLength As Long
    
    Set frmCurrentForm = Screen.ActiveForm
    If frmCurrentForm.Name = "PlayV4" Then
 
        Set ctlCurrentControl = Screen.ActiveControl
        With ctlCurrentControl
            If .Name = "MinRating" Then
                lSelStart = .SelStart
                lSelLength = .SelLength
                .Value = .Text
                .SelStart = lSelStart
                .SelLength = lSelLength
            End If
        End With
    End If
Random Solutions  
 
programming4us programming4us