Form Close Problem

ndeans

Registered User.
Local time
Today, 17:15
Joined
Jun 5, 2006
Messages
39
I have a single lingering problem preventing me from moving on with my project. I have a single form with 3 command buttons on it, Delete, Edit, Save&Close.

The form loads as default with:
Me.AllowAdditions = False
Me.AllowEdits = False
Me.AllowDeletions = False
Me.cmdDelete.Visible = False
so the form is proper locked and users can't mess things up.

Edit button works flawlessly:
Opens form in Edit mode at same time changing
Me.AllowAdditions = False
Me.AllowEdits = True
Me.AllowDeletions = True
Me.cmdDelete.Visible = True
Save and Exit then saves and exits as planned.

to delete though i set the visibility of the delete button to false as default.
selecting the edit button reveals the delete button
The delete button brings up the Delete warning i have put in the beforeDelConfirm event as follows:

Private Sub Form_BeforeDelConfirm(Cancel As Integer, _
Response As Integer)
' Suppress default Delete Confirm dialog box.
Response = acDataErrContinue
' Display custom dialog box.(you can replace it with any message you want)
If MsgBox("Are you sure you want to delete this entry?", vbOKCancel) = vbCancel Then
Cancel = True
Me.AllowDeletions = False
Me.AllowEdits = False
Me.AllowAdditions = False
End If
End Sub

Clicking OK to delete works perfectly and the form closes.
Clicking Cancel though works well, resets the form Allows to False

BUT

then when i try to Save&Close the form i get the following message:
Do you want to save the changes to the design of the form "formname"? Y/N/Cancel

I just don't know why, i don't think i've changed the form design at all.

Any help much appreciated.

ndeans
 
Last edited:
Have you looked into access Dirty Property ?

You could possibly force a save before you close to avoid the prompt.

Code:
If Me.Dirty = True Then
Me.Dirty = false
End if

JR
 
Have you looked into access Dirty Property ?

You could possibly force a save before you close to avoid the prompt.

Code:
If Me.Dirty = True Then
Me.Dirty = false
End if

JR


Nope No Go. Cheers
 
If you are using a close button that you build yourself, and you don't wish to save you can try:

DoCmd.Close , , acSaveNo

or even if you wish to save

DoCmd.Close , , acSaveYes

If you are using the little X at the top, you might be able to add this code in the "On Close" event, but I've never tested the effects of that.
 
When you use acSaveNo , that mean that you do not want to save changes to the form and has no relationship to the data on the form.

When you close a form the data will be saved to the table.

I use

Code:
DoCmd.Close acForm, Me.Name
 
Bloody Marvellous, so simple but has had me stalled all day.

Cheers very much Devastation.


If you are using a close button that you build yourself, and you don't wish to save you can try:

DoCmd.Close , , acSaveNo

or even if you wish to save

DoCmd.Close , , acSaveYes

If you are using the little X at the top, you might be able to add this code in the "On Close" event, but I've never tested the effects of that.
 
it's funny this

i've been noticing that just opening and closing a form changes the modified date/time for the from - but not all the while.

i cant pin down what circumstances change it - but it sounds like this is what is happening, perhaps
 

Users who are viewing this thread

Back
Top Bottom