MS Access - Cerrar formulario sin guardar cambios de diseño, acSaveNo no funciona

I have a Front End/Back End app in MS Access and I'm having some problems with performance when I close forms.

These forms are always saving before close because in Form_Open I hide some columns and edit the caption. Then, when I close the form, it saves the hidden columns and wastes much time!

I have already done a lot of settings modifications in Access for optimize for FE/BE. But I'm still have problems with forms that save before close. On save event it really wastes a lot of time. With the hide/edit columns routine it takes 20s to save. Without the routine it takes 1s or less, but my data is not saved.

How could I hide/edit these columns without the need to save the form afterwards? Or how could I close the form without saving structure changes?

Unfortunately Access doesn't have a BeforeClose evento, y en un Close or Unload event it saves before going to this sub, so I can't cancel it to close later in code.

Hide Code:

'show all columns
For i = 1 To 8
    Form_Y_SubF_LP.Controls("Item_00" & i).ColumnHidden = False
    Form_Y_SubF_LP.Controls("Quantity_00" & i).ColumnHidden = False
    Form_Y_SubF_LP.Controls("DistributionEQ_00" & i).ColumnHidden = False
Next
'Hide unnecessary columns
For i = 8 To ProtQuant + 1 Step -1
    Form_Y_SubF_LP.Controls("Item_00" & i).ColumnHidden = True
    Form_Y_SubF_LP.Controls("Quantity_00" & i).ColumnHidden = True
    Form_Y_SubF_LP.Controls("DistributionEQ_00" & i).ColumnHidden = True
Next

'Change the caption of columns to the real name of each prototype
prot = DLookup("[Prototype]", "Y_Configurações", "[Program]= '" & ProgramName & "'")
For i = 0 To UBound(Split(prot, ";"), 1)
    Form_Y_SubF_LP.Controls("Item_00" & i).Properties("Caption") = "Item_" & Split(prot, ";")(i)
    Form_Y_SubF_LP.Controls("Quantity_00" & i).Properties("Caption") = "Quantity_" & Split(prot, ";")(i)
    Form_Y_SubF_LP.Controls("DistributionEQ_00" & i).Properties("Caption") = "DistributionEQ_" & Split(prot, ";")(i)
Next

preguntado el 09 de marzo de 12 a las 16:03

1 Respuestas

A simple solution is to set Close Button = No on the form's property sheet, then add a command button, cmdCloseMe, with this for its On Click event:

Private Sub cmdCloseMe_Click()
    DoCmd.Close acForm, Me.Name, acSaveNo
End Sub

If you need your form displayed in Datasheet View, you would need to embed it in a subform control of another form and add the cmdCloseMe button to that form.

respondido 09 mar '12, 20:03

My form it is a datasheet.. but i'll try to do what you said.. thanks for your help! - magavo

No es la respuesta que estás buscando? Examinar otras preguntas etiquetadas or haz tu propia pregunta.