Solved

Close the form from a subform procedure

Posted on 2012-03-22
7
365 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
Comment Utility
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
Comment Utility
Just use the name of the form.

Docmd.close acform, me.parent.name
0
 

Author Closing Comment

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

Sandra
0
Maximize Your Threat Intelligence Reporting

Reporting is one of the most important and least talked about aspects of a world-class threat intelligence program. Here’s how to do it right.

 
LVL 61

Expert Comment

by:mbizup
Comment Utility
Alteratvely

Docmd.close acform,"frmunmatchedemployee"
0
 

Author Comment

by:ssmith94015
Comment Utility
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
Comment Utility
Very smart!  I wish everybody who posted here were that conscientious.
0
 
LVL 74

Expert Comment

by:Jeffrey Coachman
Comment Utility
<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

How to improve team productivity

Quip adds documents, spreadsheets, and tasklists to your Slack experience
- Elevate ideas to Quip docs
- Share Quip docs in Slack
- Get notified of changes to your docs
- Available on iOS/Android/Desktop/Web
- Online/Offline

Join & Write a Comment

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 “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…
The viewer will learn how to use the =DISCRINV command to create a discrete random variable, use this command to model a set of probabilities and outcomes in a Monte Carlo simulation, and learn how to find the standard deviation of a set of probabil…

763 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

6 Experts available now in Live!

Get 1:1 Help Now