Avatar of kevin1478
kevin1478
Flag for United Kingdom of Great Britain and Northern Ireland asked on

MS Access - prevent a form from being closed

I have a switchboard form open upon starting MS Access 2003. I want to prevent the user from closing this form. How can I do this.

Thank you.
Microsoft Access

Avatar of undefined
Last Comment
kevin1478

8/22/2022 - Mon
ee_rlee

You can set Cancel=1 on the form's unload event to prevent it from unloading.
Private Sub Form_Unload(Cancel As Integer)
If <condition> Then
    Cancel = 1
End If
End Sub

Open in new window

kevin1478

ASKER
Thank you.

I've added the code but when I slect the X to close the form I get an error
Complie Errort: syntax Error.

Upon debug the line
If <condition> Then
is highlighted.

any ideas?
ASKER CERTIFIED SOLUTION
ee_rlee

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
kevin1478

ASKER
Thank you. Sorry for been so dumb.
Experts Exchange has (a) saved my job multiple times, (b) saved me hours, days, and even weeks of work, and often (c) makes me look like a superhero! This place is MAGIC!
Walt Forbes