I'm sure this is very simple, but I can't find it. In the close event of an Access Form, how can I cancel closing the form? I have a test that counts the records in a table. If that table has records, I want to ask the user if they want to close or go back and work with them. So how do I cancel the close event?
相关问题
- Error handling only works once
- Excel formula in VBA code
- Excel VBA run time error 450 from referencing a ra
- Importing data from MS Access db to PostgreSQL db
- DoCmd.TransferSpreadsheet is not recognizing works
相关文章
- Unregister a XLL in Excel (VBA)
- numeric up down control in vba
- Declare a Range relative to the Active Cell with V
- COALESCE, IFNULL, or NZ() function that can be use
- CurrentDb.RecordsAffected returns 0. Why?
- How to disable changes in a cell using vba?
- MsgBox Yes/No Excel VBA
- Rounding up to nearest higher integer in VBA
Use the "Form_BeforeUpdate(cancel as integer)" event and set cancel to True.
Notice that you simply will not be able to close at all unless you add some logic to actually allow updating the database.
Study and try this code, it worked for me. Replace necessary variable names with your chosen names. Paste the code in the form_unload Event of your form. WARNING!!!: After you perform this operation you will find it difficult to access your form in design and layout view
You can use the Unload event:
Order of events for database objects