Hi guys! I have a problem involving 3 forms - a principal form (frmPrincipal), a form used to filter records(frmFilter), and a third form used to perform operations on the filtered data (frmContacts).

In frmFilter, I have the following code which I use to change the image on a button from a traffic light with the light red to a traffic light with the light green. This is so that the user is distracted while the records are being filtered.

Code:
cmdContinuar.Picture = Image1.Picture

HourInitial = Time
HourFinal = Time
Do While HourInitial = HourFinal
    HourFinal = Time
    DoEvents
Loop
HourInitial = Time
HourFinal = Time
Do While HourInitial = HourFinal
    HourFinal = Time
    DoEvents
Loop

Me.MousePointer = vbDefault
DoEvents

Me.Hide

With frmContacts
    If frmPrincipal.UseGroups = True Then
        .lblGroup.Caption = "Group:"
        
    Else
        .lblGroup.Caption = "Level:"
        
    End If
    
    .lblLevel.Caption = txtLevel.Text
    .lblPeriod.Caption = cmbPeriod.Text
    .Show vbModal, frmPrincipal

End With

Unload Me
On occasion, when the user enters the filter criteria, proceeds to frmContacts, and then closes frmContacts, the same form will pop open again. It only happens about 10% of the time, which leads me to believe that it has something to do with the above loops and DoEvents statements.

Why is this happening?

Thanks,

Andrew