Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

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

Posted on 2011-03-07
4
Medium Priority
?
281 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
4 Comments
 
LVL 14

Accepted Solution

by:
pteranodon72 earned 2000 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

[Webinar] Lessons on Recovering from Petya

Skyport is working hard to help customers recover from recent attacks, like the Petya worm. This work has brought to light some important lessons. New malware attacks like this can take down your entire environment. Learn from others mistakes on how to prevent Petya like worms.

Question has a verified solution.

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

AutoNumbers should increment automatically, without duplicates.  But sometimes something goes wrong, and the next AutoNumber value is a duplicate.  This article shows how to recover from this problem.
Access developers frequently have requirements to interact with Excel (import from or output to) in their applications.  You might be able to accomplish this with the TransferSpreadsheet and OutputTo methods, but in this series of articles I will di…
In Microsoft Access, when working with VBA, learn some techniques for writing readable and easily maintained code.
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

704 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