Solved

Close the form from a subform procedure

Posted on 2012-03-22
7
370 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
Ransomware: The New Cyber Threat & How to Stop It

This infographic explains ransomware, type of malware that blocks access to your files or your systems and holds them hostage until a ransom is paid. It also examines the different types of ransomware and explains what you can do to thwart this sinister online threat.  

 
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

Salesforce Made Easy to Use

On-screen guidance at the moment of need enables you & your employees to focus on the core, you can now boost your adoption rates swiftly and simply with one easy tool.

Question has a verified solution.

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

Deploying a Microsoft Access application in a Citrix environment is not difficult but takes a few steps. However, Citrix system people are often of little help, as they typically know next to nothing about Access. The script provided here will take …
Whether you've completed a degree in computer sciences or you're a self-taught programmer, writing your first lines of code in the real world is always a challenge. Here are some of the most common pitfalls for new programmers.
What’s inside an Access Desktop Database. Will look at the basic interface, Navigation Pane (Database Container), Tables, Queries, Forms, Report, Macro’s, and VBA code.
The view will learn how to download and install SIMTOOLS and FORMLIST into Excel, how to use SIMTOOLS to generate a Monte Carlo simulation of 30 sales calls, and how to calculate the conditional probability based on the results of the Monte Carlo …

679 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