Results 1 to 5 of 5
  1. #1
    Join Date
    May 2005
    Posts
    1,191

    Unanswered: Refresh Screen After Selecing Another Application

    I have some pretty heavy-duty code that loops around and does some stuff for about an hour. The code works fine. But I use the following code to give me an update on things every 10 loops (about once a second or so) and to give me an estimated time to completion:
    Code:
            'Update Status every 10
            If (j Mod 10) = 1 Then
                dblPercent = j / intRecordCount * 100
                SysCmd acSysCmdInitMeter, _
                        "Working (" & _
                           Format(((100 / dblPercent) - 1) * (Now - dtmStart), "Hh:Nn:Ss") & _
                           " ETR)...", _
                        intRecordCount
                SysCmd acSysCmdUpdateMeter, j
                'DoCmd.RepaintObject
                'Me.Form.Repaint
                'Me.Application.RefreshDatabaseWindow
            End If
    The code works fine right after I start the code going. But of course I don't want to just stare at an updating screen for an hour, so I'll often go work on something else or check my email or whatever while this chugs away in the background. But when I select the application again, it won't update that status anymore, it just stays at whereever it was when the application lost focus.

    As you can see I've tried a few different ways to try to get the screen to refresh, but so far with no luck. Any suggestions?
    Me.Geek = True

  2. #2
    Join Date
    Dec 2004
    Location
    Madison, WI
    Posts
    3,926
    The repaint command should work but I put the specific form name in the command (as sometimes you can lose the focus to another form/event/other app).

    ex:

    Forms!MyFormName.repaint (versus me.form.repaint or me.repaint)

    Also, if you're curious, I think there's a "Progress Bar" example in the code bank which is kind of neat.
    Last edited by pkstormy; 03-31-09 at 22:07.
    Expert Database Programming
    MSAccess since 1.0, SQL Server since 6.5, Visual Basic (5.0, 6.0)

  3. #3
    Join Date
    May 2005
    Posts
    1,191
    Hey pk,

    I just tried explicitly calling the form like you suggested, but still no luck. I'm beginning to wonder if it's because it's being run on a XP 64-bit edition, I know I've had other quirky things because of that. Oh well, thanks anyways!
    Me.Geek = True

  4. #4
    Join Date
    Dec 2004
    Location
    Madison, WI
    Posts
    3,926
    Hey Nick,

    Maybe setting the focus to the form first might work (even though the form should have the focus).

    Forms!MyForm.setfocus
    Forms!MyForm.repaint

    You could also put in a msgbox on the LostFocus event of the form to see if the focus is being lost from the form. (you could also try the .repaint in the OnFocus or OnActivate (or one of those types of events) of the form.) I sometimes throw in a whole bunch of msgbox's on different events of the form to try and see what's going on and the possible problem.

    I recall having the same type of problem once as you're having but I can't remember what I did to solve it (or if I did solve it.) I think I may have put the .repaint command in the OnFocus or one of those events of the form.

    I'm curious. Let me know.
    Last edited by pkstormy; 04-03-09 at 14:58.
    Expert Database Programming
    MSAccess since 1.0, SQL Server since 6.5, Visual Basic (5.0, 6.0)

  5. #5
    Join Date
    May 2005
    Posts
    1,191
    I tried messing some more with it, but couldn't get the syscmd to refresh. So I resorted to having a textbox on the form, putting the status updates in that, and then refreshing the form. Seems to work, though not ideal. Oh well. Thanks!
    Me.Geek = True

Posting Permissions

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