|
-
Nov 7th, 2000, 08:10 PM
#1
Thread Starter
Member
i have a timer event in my app that checks a condition, if the condition is true then i popup a display form, however; i get an error if a modal form is already open. i have good error code in my app. the very first line is similiar to this.
On Error GoTo Timer1_Timer_Err
but on my timer event condition true i have to do something like this to keep from getting an error.
On Error Resume Next
frmCalendarReminder.Show
On Error GoTo Timer1_Timer_Err
is there a way to detect an open modal form, then i can just wrap the form.show around and if statement. thanks...
jj
-
Nov 7th, 2000, 08:20 PM
#2
This code will determine if a form is already open.
Code:
Tip by Sam Huggill
Public Function FormLoadedByName(FormName As String) As Boolean
Dim i As Integer, fnamelc As String
fnamelc = LCase$(FormName)
FormLoadedByName = False
For i = 0 To Forms.Count - 1
If LCase$(Forms(i).Name) = fnamelc Then
FormLoadedByName = True
Exit Function
End If
Next
End Function
Private Sub Command1_Click()
If FormLoadedByName("Form2") = True Then
MsgBox "Form2 is loaded"
Else
MsgBox "Form2 is not loaded"
End If
End Sub
-
Nov 7th, 2000, 08:27 PM
#3
Thread Starter
Member
That would work, however; my project has many modal forms so i have have to do a dectect on each of them. Does anyone have any comments on this option. I know the error number that is raised if I try to show a form and a modal form is already open, so i could continue to use the On Error Resume Next, then put an if after the form.show line that says if err.number <> 420 (420 is the error raised in this case) then goto my error handling code. I don't like to use On Error Resume Next, but as of now I don't have any other options.
jj
-
Nov 8th, 2000, 01:07 AM
#4
Frenzied Member
Why don't you use a global variable to track the status of open, modal forms? You would just set the variable to true when a modal form is opened, and set it back to false when that form closes. You then just check the variable before attempting to open another modal form.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|