Solved

Close the form from a subform procedure

Posted on 2012-03-22
7
366 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
  • 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
U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

 
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

U.S. Department of Agriculture and Acronis Access

With the new era of mobile computing, smartphones and tablets, wireless communications and cloud services, the USDA sought to take advantage of a mobilized workforce and the blurring lines between personal and corporate computing resources.

Question has a verified solution.

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

A theme is a collection of property settings that allow you to define the look of pages and controls, and then apply the look consistently across pages in an application. Themes can be made up of a set of elements: skins, style sheets, images, and o…
This collection of functions covers all the normal rounding methods of just about any numeric value.
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …
The viewer will learn how to create a normally distributed random variable in Excel, use a normal distribution to simulate the return on an investment over a period of years, Create a Monte Carlo simulation using a normal random variable, and calcul…

932 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

14 Experts available now in Live!

Get 1:1 Help Now