Solved

Close the form from a subform procedure

Posted on 2012-03-22
7
372 Views
Last Modified: 2012-03-22
I have a mainform/subform.  On teh subform next to the record is an edit button that does call another form for a particular record and works find. But I want to close this first form in the code, but since it is on the sub-form, it does not close the entire form at all.

 DoCmd.OpenForm "frmEmployees", , , "[EmpUserID]= '" & strUserID & "' " -THIS WORKS
 DoCmd.Close acForm, Me.Parent.frmEmpsNoJobID - THIS DOES NOT

The main form is called frmUnmatchedEmpoyees.  This is an Access 2003 form.

Sandra
0
Comment
Question by:ssmith94015
[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
  • 3
  • 2
  • 2
7 Comments
 
LVL 74

Expert Comment

by:Jeffrey Coachman
ID: 37754864
it is not clear from your post what objects are open and when....

It is also not clear what form you are on and what form you want to close

(Or even why you would want to close a form that you are not currently in/on...?

You say things like "I want to close this first form"
...but it is not clear what form you have designated as the "First form"

This is why a sample database is *Much* easier to work from than a complex description...

Or instead refer to your forms as FormA, FormB, FormC, ...etc
0
 
LVL 61

Accepted Solution

by:
mbizup earned 500 total points
ID: 37754873
Just use the name of the form.

Docmd.close acform, me.parent.name
0
 

Author Closing Comment

by:ssmith94015
ID: 37754882
That did it.  I had assumed when the sames said Name, I shoudl type the name of the subform!

Sandra
0
Windows Server 2016: All you need to know

Learn about Hyper-V features that increase functionality and usability of Microsoft Windows Server 2016. Also, throughout this eBook, you’ll find some basic PowerShell examples that will help you leverage the scripts in your environments!

 
LVL 61

Expert Comment

by:mbizup
ID: 37754883
Alteratvely

Docmd.close acform,"frmunmatchedemployee"
0
 

Author Comment

by:ssmith94015
ID: 37754899
Jeff, part of the reason I don't post the databases is that I am at a finanicial institutions and every thing is confidential with a lot of client data, transaction, account numbers etc.  When I encounter a problem during the day, I simply cannot clean out the database in order to post it, but need to try to describe the problem as best I can without loading any data.  It is a bit cumbersome, but is the environment I have to work with.
0
 
LVL 61

Expert Comment

by:mbizup
ID: 37754918
Very smart!  I wish everybody who posted here were that conscientious.
0
 
LVL 74

Expert Comment

by:Jeffrey Coachman
ID: 37755654
<Jeff, part of the reason I don't post the databases is that...>

I understand, ...just in a lot of cases I find that the issue can quickly be resolved by the simple saying I always use...
    "Just show me what you have, ...then show me what you want..."  

;-)

Jeff
0

Featured Post

Use Case: Protecting a Hybrid Cloud Infrastructure

Microsoft Azure is rapidly becoming the norm in dynamic IT environments. This document describes the challenges that organizations face when protecting data in a hybrid cloud IT environment and presents a use case to demonstrate how Acronis Backup protects all data.

Question has a verified solution.

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

As tax season makes its return, so does the increase in cyber crime and tax refund phishing that comes with it
This article describes two methods for creating a combo box that can be used to add new items to the row source -- one for simple lookup tables, and one for a more complex row source where the new item needs data for several fields.
With Microsoft Access, learn how to specify relationships between tables and set various options on the relationship. Add the tables: Create the relationship: Decide if you’re going to set referential integrity: Decide if you want cascade upda…
With Secure Portal Encryption, the recipient is sent a link to their email address directing them to the email laundry delivery page. From there, the recipient will be required to enter a user name and password to enter the page. Once the recipient …
Suggested Courses

626 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