Solved

Closing forms

Posted on 2009-07-07
5
312 Views
Last Modified: 2013-11-28
I have a form that, when I'm entering data, uses information from another form.

What I'd like to do is
1. Save the current record (easy enough: just close the form)
2. Close the OTHER form before closing the currently open one, but making sure that the information I'm am getting (e.g. a customer number) gets into the table.
3. Close the current form.

I've done a lot of searching, but I can't seem to find anything.

Thanks,

ep
0
Comment
Question by:ericpete
5 Comments
 
LVL 19

Accepted Solution

by:
darbid73 earned 175 total points
ID: 24792263
Basically closing forms you will need these if you put it in this order then OtherForm will close first and then currently open will.

You have to decide where you put this - if you make a button for it or it is somehow otherwise triggered.


DoCmd.Close acForm, "OtherForm"
DoCmd.Close acForm, "CurrentlyOpen"
0
 
LVL 6

Assisted Solution

by:Yadtrt
Yadtrt earned 150 total points
ID: 24792545
To make sure that the value has been added to the current form use:

if not isnull(The Value) then
DoCmd.Close acForm, "OtherForm"
DoCmd.Close acForm, "CurrentlyOpen"
else
msgbox " No value has been added to the form")
end if
0
 
LVL 19

Expert Comment

by:darbid73
ID: 24792585
Yes you are going to have to fill in more details of what the user can do and when they can do it.  Yadtrt has for example added one possibility, which assumes that users must enter information in this textbox(or whatever control it is).

I assumed that these forms are bound and thus letting Access to all the saving work.
0
 
LVL 5

Assisted Solution

by:bboswell
bboswell earned 175 total points
ID: 24792649
Think about it differently. Why do you look at it that you need to close the Form first.

Do it in the following steps
1. Save the current record. (This will ensure you save the "other" form dependent data )
2. Close "other" form
3. Close Current Form

'Step 1 Save Current Record
DoCmd.RunCommand acCmdSaveRecord
'Step 2 Close other Form
DoCmd.Close acForm, "Other"
'Step 3 Close Current Form
DoCmd.Close acForm, "Current"
0
 
LVL 15

Author Comment

by:ericpete
ID: 24800043
Thanks.

I was mostly just not remembering the DoCmd.RunCommand part.

ep
0

Featured Post

How to run any project with ease

Manage projects of all sizes how you want. Great for personal to-do lists, project milestones, team priorities and launch plans.
- Combine task lists, docs, spreadsheets, and chat in one
- View and edit from mobile/offline
- Cut down on emails

Join & Write a Comment

In the previous article, Using a Critera Form to Filter Records (http://www.experts-exchange.com/A_6069.html), the form was basically a data container storing user input, which queries and other database objects could read. The form had to remain op…
A simple tool to export all objects of two Access files as text and compare it with Meld, a free diff tool.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

747 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

17 Experts available now in Live!

Get 1:1 Help Now