PC Review


Reply
Thread Tools Rate Thread

Close popup form from a continuous subform

 
 
0 1
Guest
Posts: n/a
 
      27th Jan 2011
I have a continuous subform (fsubEvents) that lists various patient
events that have been entered for each patient (a well-check visit, a
lab test, etc.).

When you click on an event, OnClick code opens a pop-up form showing
that event's information. When the user selects a different event from
the continuous subform, I'd like to close the currently open event
form (if there is one), and open the next relevant form.

Because each type of event has its own form, it's difficult to know
which form may have just been opened, so this won't work:

If IsLoaded("PopUpFormName") = True Then
DoCmd.Close acForm, "PopUpFormName"
End If

.... unless there's a way to find the name of the currently open popup
form and pass that to the IsLoaded argument. Or is there a better way
to address this?

Thank you for any suggestions.
 
Reply With Quote
 
 
 
 
0 1
Guest
Posts: n/a
 
      28th Jan 2011
> 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
 
Reply With Quote
 
0 1
Guest
Posts: n/a
 
      2nd Feb 2011
This is the code that follows stDocName = rstTemp("EventFrm") :

stLinkCriteria = "[EventID]=" & rstTemp![EventID]
DoCmd.openForm stDocName, , , stLinkCriteria
ActivePopUpForm = stDocName
Forms(stDocName).Controls("PatientID").Value = Me.Parent!
PatientID
rstTemp.Close
Exit Sub

Notice the rstTemp.Close. Could that be the culprit?
 
Reply With Quote
 
0 1
Guest
Posts: n/a
 
      12th Feb 2011
Figured this out. One of my event forms had a requery line in the
AfterUpdate event, which ran while the recordset was still being
manipulated. It was requerying the continuous subform. This moved it
to the first record, and since my forms opened based on the record
(and form category) criteria, it was opening a form for the first
record.


 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Continuous Subform within a Continuous Form - Possible? AR51NAL Microsoft Access Forms 2 23rd Jun 2009 12:19 PM
Sum in Text box on Subform or main form (subform is a Continuous form) datahead22 Microsoft Access Form Coding 0 24th Aug 2007 05:00 PM
Pass selection from popup form listbox to record on continuous subform kheisler6@cox.net Microsoft Access Form Coding 6 9th Oct 2006 07:50 PM
Linking Popup to continuous Subform =?Utf-8?B?Sm9obiBQcml0Y2hhcmQ=?= Microsoft Access Form Coding 7 18th Aug 2006 06:36 PM
Continuous subform per continuous form element capkrugers@gmail.com Microsoft Access Forms 0 19th Jul 2006 07:10 PM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 06:34 PM.