Solved

Closing forms

Posted on 2009-07-07
5
333 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 20

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 20

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

Three Reasons Why Backup is Strategic

Backup is strategic to your business because your data is strategic to your business. Without backup, your business will fail. This white paper explains why it is vital for you to design and immediately execute a backup strategy to protect 100 percent of your data.

Question has a verified solution.

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

When you are entering numbers in a speadsheet, and don't remember what 6×7 is, you just type “=6*7" instead. It works in every cell! This is not so in Access. To enter the elusive 42 in a text box, you have to find a calculator, and then copy the re…
Describes a method of obtaining an object variable to an already running instance of Microsoft Access so that it can be controlled via automation.
With Microsoft Access, learn how to start a database in different ways and produce different start-up actions allowing you to use a single database to perform multiple tasks. Specify a start-up form through options: Specify an Autoexec macro: Us…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

808 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