Solved

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

Posted on 2011-03-07
4
255 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

Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

Question has a verified solution.

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

Suggested Solutions

Experts-Exchange is a great place to come for help with solutions for your database issues, and many problems are resolved within minutes of being posted.  Others take a little more time and effort and often providing a sample database is very helpf…
Phishing attempts can come in all forms, shapes and sizes. No matter how familiar you think you are with them, always remember to take extra precaution when opening an email with attachments or links.
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 the trick to repeating sub-report headings at the top of each page. The problem with sub-reports and headings: Add a dummy group to the sub report using the expression =1: Set the “Repeat Section” property of the dummy…

773 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