I'm trying to stop a form and go back the form that called it. The calling form is fmMain and the called form is fmStatus.
I'd like fmStatus to recognize when it is not visible and automatically return to fmMain. fmStatus has a comm communication where it constantly polls a comm port and updates the screen. I've tried putting this recognition in the comm logic to bail out, but it didn't work. I was hoping that clicking on the red X on the form would be sufficient to stop fmStatus.
For Each frm In Forms
If frm.Name = "fmStatus" Then
If frm.Visible = False Then
Unload fmStatus
Load fmMain
Exit Function
End If
End If
Next
If also added a 'CLOSE' button on fmStatus to try to bail out:
Private Sub CmdStatusClose_Click()
Do Until fmStatus.Visible = False
Unload fmStatus
fmStatus.Show = False
Loop
Load fmMain
End Sub
When I step thru the CLOSE button logic, it jumps out of the loop routine and goes to the Private Sub Form_Load() where the fmStatus.Show is called in the first place, so it doesn't shut down fmStatus.
Any help would be greatly appreciated.
Gary
I'd like fmStatus to recognize when it is not visible and automatically return to fmMain. fmStatus has a comm communication where it constantly polls a comm port and updates the screen. I've tried putting this recognition in the comm logic to bail out, but it didn't work. I was hoping that clicking on the red X on the form would be sufficient to stop fmStatus.
For Each frm In Forms
If frm.Name = "fmStatus" Then
If frm.Visible = False Then
Unload fmStatus
Load fmMain
Exit Function
End If
End If
Next
If also added a 'CLOSE' button on fmStatus to try to bail out:
Private Sub CmdStatusClose_Click()
Do Until fmStatus.Visible = False
Unload fmStatus
fmStatus.Show = False
Loop
Load fmMain
End Sub
When I step thru the CLOSE button logic, it jumps out of the loop routine and goes to the Private Sub Form_Load() where the fmStatus.Show is called in the first place, so it doesn't shut down fmStatus.
Any help would be greatly appreciated.
Gary