There are numerous situations in which you might want to know if a form is open, or loaded. The following scenario will help illustrate when and why to use the IsLoaded property. In this situation, a user may have several forms open, including frmEvent, which lists the names of everyone scheduled to participate in an event. Say that one of the participants cancels, so the user opens a participant form and clicks a command button (cmdCancel) to remove that participant from the event. Because the event form is already open, the data that it displays cannot be updated without some action being taken. One approach is to include code behind cmdCancel on the participant form to see if the event schedule form is open by using the event IsLoaded. If the form, frmEvent, is not open, the regular cancellation process continues. If frmEvent is open, the appropriate actions — such as closing the event schedule form or requerying the event form after canceling the appointment — should also be included in the code behind cmdCancel. The snippet below is an example of code that could be used in this scenario.

If frmEvent.IsLoaded Then

frmEvent.Requery ...

'add additional actions

End If

Consider another example: Perhaps you want users to be able to open a form in a specific way, such as only from a specified form, and definitely not from the Navigation pane. In that case, you may also first want to determine if the form is already open. The following example uses the IsLoaded property to see if a particular form is open before it continues code execution. In the code, CurrentProject refers to the open database and for illustration purposes, frmEvent is used again:

Private Sub cmdCancel_Click()

If Not CurrentProject.AllForms("frmEvent")

.IsLoaded Then

Msgbox "Cannot cancel while 'frmEvent'

form is open.",

vbInformation + VBOkOnly, "Cancel


Exit Sub

End If

End Sub

As you can see, the IsLoaded property is a convenient and useful way to determine if a form is open.

Was this article helpful?

0 0


  • elio lettiere
    Where can I find isloaded for access 2007?
    9 years ago

Post a comment