DoCmd close

Pavczech

Registered User.
Local time
Today, 19:47
Joined
Jul 11, 2012
Messages
41
Hello

Is there code which would close the form without recording it in table or specific fields?

something like DoCmd.close acform "Form" acdontsave

Thanks
 
The word is, acSaveNo

I guess it should have come up in your editor??
 
Hi
my understanding of acsaveno is to save the form but nothing to do with the data on the form.
thanks
 
Try a DoCmd.RunCommand acCmdUndo before the Close?
 
All code of this ilk belongs in the FORM's BeforeUpdate event. That is the LAST event that runs before the dirty record is saved. You can prompt to save it and if the user ansers No, you can cancel the update event and undo the changes -

Cancel = True
Me.Undo

There is NO OTHER EVENT that will trap updates in ALL CASES.

If you don't want the form to be able to update data at all, set its AllowUpdates, AllowDeletions, and AllowEdit properties to False.
 
Hi I have tried the Form's beforeupdate event and it stops from recording the whole form.

Is there any way how to stop only certain records?

I have this code and I would like it to undo only those 3 records "firstName","Surname" and MonthOfBirth", but record the rest on another related table

Private Sub Form_BeforeUpdate(Cancel As Integer)
If DCount("[FirstName]", "[VisitorsBook-Personal]", "[FirstName] ='" & Forms![VisitorsBookIn]![FirstName] & "' AND [Surname] ='" & Forms![VisitorsBookIn]![Surname] & "' AND [MonthOfBirth] ='" & Forms![VisitorsBookIn]![MonthOfBirth] & "' ") > 0 Then
Cancel = True
Me!FirstName.Undo
Me!Surname.Undo
Me!MonthOfBirth.Undo
End If
End Sub

Thanks
 
Why not try in them in the relevant Text box before update event?
 
I have tried but when I did it it wouldn't let me input the last record.
It wouldnt accept the "monthofBirth" if that record already existed.
 

Users who are viewing this thread

Back
Top Bottom