Full Version: Why Does Access Open A New Window?
UtterAccess Discussion Forums > Microsoft® Access > Access Q and A
Cheesysocks
Odd one this.
My control panel has an event when it loops through a 30,000+ set of records. It has a counter set up so the user can see the percentage done [1], it takes about 20 seconds. At about 20% (it varies between 15% to 25%) the counter on the control panel will freeze, Access will open a new window showing the purple Access 'key' logo and set focus to it. The program will continue and after a while the report is generated and this new window goes away. All else works, but the counter freezes at whatever %age it was at.
If I try to open the window during this time nothing happens, it can't be opened. It's just visual, but why does it happen? I am in design mode with all the menus available. I haven't tried it with the editors locked out yet.
Any clues please?
[1] It only updates every 100 loops around the recordset to reduce flicker.
pere_de_chipstick
Hi Mike
If you follow the update with a form repaint command
DoCmd.RepaintObject acForm, "YourFormName"
This should stop the form apparently freezing
Also, where you are updating the % control, if you only update the control if it needs changing then this will stop the flicker e.g.
IF Me.ControlName <> CalculatedPercentValue then Me.ControlName = CalculatedPercentValue
hth
Cheesysocks
Thanks for the reply. This is what I'm currently doing, this loops just over 30,000 records at the moment.
!--c1-->
CODE
Do Until rstIn.EOF
    
    'Show a counter to the user on the button
    'The loop is to reduce flickering when redrawing the caption.
    If intRefreshRate = 100 Then
        lblPercentCounter.Caption = Int((i / intNumberOfRecords) * 100) & " %"
        Me.Repaint
        intRefreshRate = 0
    End If
    intRefreshRate = intRefreshRate + 1
    
        'Do the Work inside the loop....
    'Increase the users counter
    i = i + 1
Loop
niesz
You may need to add a DoEvents line, if the Repaint doesn't work.
Cheesysocks
Nearly 6 pm here and I'm off home. I'll try this tomorrow, thanks.
merlenicholson
If I may make a different suggestion .. You may have better luck disconnecting the two actions with the form timer event. I'd update a form variable within the code with the number you need. At the start of the processing loop, set the timer interval to something other than zero, and let the timer calculate and update the caption. When the processing ends, set the timerinterval to zero. I don't think you'll have to refresh anything. Access may even have the smarts to assign it to another thread.
Cheesysocks
Good morning all.
The DoEvents line fixed it perfectly. The timer idea sounded promising but this was quicker and easier in the end. As usual, my thanks to all of you who give your time.
Mike.
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.