> If your popup forms follow a distinctive naming convention,
> you could loop through the Forms collection checking if one
> (or more) are open.
Unfortunately, they don't follow a convention that would lend itself
to looping.
> An alternative could be to park the name in a module level
> variable so you can retrieve it when another event is
> selected.
Hmm ... The subform's OnClick code that opens the pop up form in the
first place has to find the name of the form (it looks up the form
name in a table based on a hidden value on the subform). It assigns
it to stDocName (stDocName = rstTemp("EventFrm") and uses it like so:
DoCmd.openForm stDocName, , , stLinkCriteria
So I added this line after it:
ActivePopUpForm = stDocName
.... then put this at the top of the form's module area:
Dim ActivePopUpForm As String
.... and added this to the start of the OnClick code:
If IsLoaded(ActivePopUpForm) = True Then
DoCmd.Close acForm, ActivePopUpForm
End If
It works most of the time. It fails, I think, when I a patient has
several of the same type events(e.g., a Well Check visit on 1/2/2010
and one on 5/3/2012). After clicking on the second instance, things
get screwy and sometimes an earlier assigned form is opened. That
suggests that ActivePopUpForm is sometimes being assigned to
stDocName, when I always want to be the other way around.
Could it be a problem with this line?:
ActivePopUpForm = stDocName
|