I have a SearchResults form that is used to input a search criteria. When the user is ready to display the results found they press the find button. All the results found based on the search criteria will be displayed in a listbox (searchResultsFound) on the SearchResults form.
Since the search can generally take 10 seconds to 1 minute to display results in the list box. I created a PleaseWait form that will appear once the find button has been clicked and will be displayed until the results are shown in the list box. The PleaseWait form has a simple animation of squares that change colours. If I open the form on its own, the animation works. Form and Code shown below.
Note: The results displayed are coming from a table with more than 1 million records
Code for the PleaseWait form below:
Public Sub Form_Timer()
Dim beforecolour As Long
Dim afterColour As Long
beforecolour = RGB(140, 140, 140)
afterColour = RGB(255, 9, 9)
ClockName = ClockName + 1
If ClockName > 6 Then
ClockName = 1
Me.b1.BackColor = colour
Me.b2.BackColor = beforecolour
Me.b3.BackColor = beforecolour
Me.B4.BackColor = beforecolour
Me.b5.BackColor = beforecolour
Me.b6.BackColor = beforecolour
End If
Select Case ClockName
Case 1
Me.b1.BackColor = afterColour
Case 2
Me.b2.BackColor = afterColour
Case 3
Me.b3.BackColor = afterColour
Case 4
Me.B4.BackColor = afterColour
Case 5
Me.b5.BackColor = afterColour
Case 6
Me.b6.BackColor = afterColour
End Select
End Sub
When the user clicks on the find button, the PleaseWait form appears and does everything it is meant to do, except for the simple animation. Shown Below.
The code behind the find button shown below.
DoCmd.OpenForm "PleaseWait"
DoCmd.RepaintObject , PleaseWait
Forms![searchResults]![searchResultsFound].RowSource = "SearchResults-BasedOnSearchCriteria"
Forms![searchResults]!recordCount.Value = DCount("*", "SearchResults-BasedOnSearchCriteria")
DoCmd.Close
SearchResults-BasedOnSearchCriteria = A Query
After trying all sorts of things, the following lines in the code is the problem. If I take these out the animation on the PleaseWait box works
Forms![searchResults]![searchResultsFound].RowSource = "SearchResults-BasedOnSearchCriteria"
Forms![searchResults]!recordCount.Value = DCount("*", "SearchResults-BasedOnSearchCriteria")
Does anyone have any ideas, or is there a way to force the PleaseWait form to Open and begin animation before setting the row source for the list box?
Any help would be greatly appreciated