Question : Closing a form with docmd.close

Access 97.  In the procedure of a button on my form, I am using docmd.close to close the form.  However, it always closes the form instantly without saving or asking to save the record.  Now, you'll probably tell me to add "acSavePrompt" or something to the docmd.close line.  Well I have.  It doesn't care!  I look at the Access help and it tells me that this syntax will cause Access to prompt to save the record.  It just exits!!  What the *(@&@!!  I'm sorry but this is crazy.

DoCmd.Close acForm, "Manual Check Form", acSavePrompt

Answer : Closing a form with docmd.close

acSavePrompt doesnt't mean that it will save the current record.  It refers to changes made to the design of the form (like property changes).

If you want it to save before it closes, try adding:

DoCmd.RunCommand acCmdSaveRecord

before you actually do the DoCmd.Close.  If you want a prompt, you could probably add on by doing the following:

Dim intResponse As Integer
intResponse = MsgBox("Save changes?",vbYesNo)
If intResponse = vbYes Then
     DoCmd.RunCommand acCmdSaveRecord
End If






Random Solutions  
 
programming4us programming4us