Solved

How can I hide a form when closing and opening another?

Posted on 2011-03-07
4
267 Views
Last Modified: 2012-05-11
I have a main form called "frmMainHome" it has a subform called " frmSubUpdates". On the subform there is a button that closed the main form "frmMainHome" and opens another form called"frmsubjectedit" The problem is when I click the button to open "frmsubjecteidt" , frmMainform is still present as the new form is opening. How can i referr to the parent form form teh subform to hide before it closes and opens frmsubjectedit. i am looking from a cleaner look. The cose is from the subform event.
Dim stDocName As String
Dim stLinkCriteria As String
Dim subjectid As String
subject = Me.subjectid
stLinkCriteria = "casestatus = 'Open'"
stStatusCriteria = """Open"""
stDocName = "frmsubjectedit"
   
stLinkCriteria = "subjectid=" & subject
DoCmd.OpenForm stDocName, , , stLinkCriteria, acFormEdit, OpenArgs:="frmMainHome" & ";" & stStatusCriteria
DoCmd.Close acForm, "frmMainhome"

Open in new window

0
Comment
Question by:seanlhall
  • 2
4 Comments
 
LVL 14

Accepted Solution

by:
pteranodon72 earned 500 total points
ID: 35062608
One approach is to turn off screen updating until everything is done:

DoCmd.Echo = False
'open the new form here

'close the form here

DoCmd.Echo = True

(you'll want to put DoCmd.Echo = True into your forms' error handlers if you use this, otherwise errors will make Access unresponsive.)

The other possibility is to hide the currently showing form with:
DoCmd.OpenForm "ShowingFormName",,,,,acHidden
(6th parameter is acHidden)

To find the name of the parent form of the code-running subform:

stDocName = Me.Parent.Form.Name

Hope this helps,
pT72
0
 
LVL 74

Expert Comment

by:Jeffrey Coachman
ID: 35070574
<No Points wanted>

There are other ways to do this that are more complicated as well.
You can search here for your question text for some examples
(Like storing the previous form's name and closing it, ...etc)

pteranodon72 has covered the most popular, so go with that...


;-)

JeffCoachman
0
 
LVL 74

Expert Comment

by:Jeffrey Coachman
ID: 35070627
pteranodon72,

I try to only use the Echo method if I am using a version of Access prior to when the hidden argument was available.
(I believe the hidden argument was around a long time in Forms, but this argument was first introduced in Reports in Access 2002, I think...)

You also need a good error handler, to turn the screen back on in case of an error...
;-)

Jeff

0
 

Author Closing Comment

by:seanlhall
ID: 35072684
Excellent!!
0

Featured Post

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In a multiple monitor setup, if you don't want to use AutoCenter to position your popup forms, you have a problem: where will they appear?  Sometimes you may have an additional problem: where the devil did they go?  If you last had a popup form open…
In Part II of this series, I will discuss how to identify all open instances of Excel and enumerate the workbooks, spreadsheets, and named ranges within each of those instances.
Familiarize people with the process of utilizing SQL Server functions from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Ac…
In Microsoft Access, learn how to “cascade” or have the displayed data of one combo control depend upon what’s entered in another. Base the dependent combo on a query for its row source: Add a reference to the first combo on the form as criteria i…

679 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question