PDA

View Full Version : Application.Echo / DoCmd.Echo resets when Form is closed



Capema02
11-12-2019, 07:18 PM
I have VBA code to close 3 Forms after clicking a Command Button. The Forms close just fine, but there is a lot of flickering while they close so I wanted to turn off the screen updating using Application.Echo or DoCmd.Echo. However, once any of the Forms close, it appears the screen updating setting resets. How can I get the .Echo to remain in place while all the Forms close?




DoCmd.Echo False

If CurrentProject.AllForms("Form_1").IsLoaded Then
DoCmd.RunCommand acCmdSaveRecord
DoCmd.Close
End If

If CurrentProject.AllForms("Form_2").IsLoaded Then
DoCmd.RunCommand acCmdSaveRecord
DoCmd.Close
End If

If CurrentProject.AllForms("Form_3").IsLoaded Then
DoCmd.RunCommand acCmdSaveRecord
DoCmd.Close
End If

DoCmd.Echo True



Note, I've tried this in the Click, Mouse Down, and Mouse Up Events of the Command Button.

OBP
11-13-2019, 03:35 AM
I have never used the Echo function while closing Forms and do not know why it would reset after a form is closed.
To overcome the problem I think I would add the Domcd.Echo False within each of the If/End If groups.
You also should not need to force a save record when closing a form, Access normally does it automatically.

Capema02
11-13-2019, 07:13 AM
Thanks OBP, I changed the code to the following since I don't need to check if they're open, I know they're open. Runs much smoother now.




DoCmd.Echo False
DoCmd.Close acForm, "Form 1"
DoCmd.Echo False
DoCmd.Close acForm, "Form 2"
DoCmd.Echo False
DoCmd.Close acForm, "Form 3"
DoCmd.Echo True