Solved

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

Posted on 2011-03-07
4
236 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
Comment Utility
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
Comment Utility
<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
Comment Utility
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
Comment Utility
Excellent!!
0

Featured Post

IT, Stop Being Called Into Every Meeting

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

QuickBooks® has a great invoice interface that we were happy with for a while but that changed in 2001 through no fault of Intuit®. Our industry's unit names are dictated by RUS: the Rural Utilities Services division of USDA. Contracts contain un…
A simple tool to export all objects of two Access files as text and compare it with Meld, a free diff tool.
Familiarize people with the process of utilizing SQL Server views 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 Access…
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…

744 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now