Closing forms

  • Thread starter Thread starter MartinR
  • Start date Start date
M

MartinR

Hey I know this is a simple problem but I just can't figure it out!
When I'm in a form and I want to close a seperate form, saving the
information stored in it what code should I use??

I think the start of it should be:

DoCmd.Close([acForm],[New Cable],acSaveYes.........

I just dont know how to finish the statement! I'd appriciate any help!
Thanks!
 
DoCmd.Close acForm, "New Cable", acSaveYes

Pieter

MartinR said:
Hey I know this is a simple problem but I just can't figure it out!
When I'm in a form and I want to close a seperate form, saving the
information stored in it what code should I use??

I think the start of it should be:

DoCmd.Close([acForm],[New Cable],acSaveYes.........

I just dont know how to finish the statement! I'd appriciate any help!
Thanks!
 
The acSaveYes does not save the record.
It refers to saving any design changes.

Set the Dirty property of the form to No to save the record.

This kind of thing:
Dim strForm As String
strForm = "New Cable"
If CurrentProject.AllForms(strForm).IsLoaded Then
If Forms(strForm).Dirty Then
Forms(strForm).Dirty = False
End If
DoCmd.Close acForm, strForm
End If
 
Martin,

DoCmd.Close acForm, "New Cable"

Saving is not necessary - if you are already using another form, the
data on the New Cable form will already be saved - it can't be
otherwise, as the data is updated to the table as soon as you move to
another record, or close the form, or move the focus from the form. In
any case, the acSaveYes etc arguments related to the Close method do not
refer to data, theyrefer to savingdesign changes to the object.
 
Steve said:
... as the data is updated to the table as soon as you move to
another record, or close the form, or move the focus from the form.

My apologies, this is incorrect. Well, the first part of it is correct
:-), but moving the focus to another form does not automatically save
the data - it is possible for the focus to be on one form at the same
time another form is dirty.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top