Go Back   Access World Forums > Microsoft Access Discussion > Modules & VBA

 
Reply
 
Thread Tools Rate Thread Display Modes
Old 12-20-2012, 11:10 AM   #1
adi2011
Newly Registered User
 
Join Date: May 2011
Posts: 60
Thanks: 9
Thanked 0 Times in 0 Posts
adi2011 is on a distinguished road
How to make control when user clicks on Exit button of Form to warn user about...?

Hello,

I really hope someone can help me with this, please see screen first as it explains a lot:



If user didn't fill any record on form named "Test form" you see on picture I would like to sett warning message, and If user did fill one or more record, then user can exit without any warning message! How can I achieve that?

Any help is appreciated!

Cheers
Adi

adi2011 is offline   Reply With Quote
Old 12-20-2012, 11:17 AM   #2
AccessMSSQL
Seasoned Programmer-ette
 
Join Date: May 2012
Location: Los Angeles, California
Posts: 636
Thanks: 1
Thanked 111 Times in 109 Posts
AccessMSSQL will become famous soon enough AccessMSSQL will become famous soon enough
Re: How to make control when user clicks on Exit button of Form to warn user about...

It depends on how you are using this form. Is it only for adding new records? or can the user open this form and see existing records also. If this is only a dataentry form then use this code:
Code:
 
if me.recordset.recordcount = 0 then
   if msgbox("You have not entered any records.  Are you sure you want to close?",vbYesNo+vbDefaultButton1+vbQuestion,"Close Form?") = vbYes then
      docmd.close acform, "yourformname"
   end if
end if
__________________
Cheryl

To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.


To view links or images in signatures your post count must be 10 or greater. You currently have 0 posts.

***********************
please mark threads complete if issue is resolved!
AccessMSSQL is offline   Reply With Quote
The Following User Says Thank You to AccessMSSQL For This Useful Post:
adi2011 (12-20-2012)
Old 12-20-2012, 01:48 PM   #3
adi2011
Newly Registered User
 
Join Date: May 2011
Posts: 60
Thanks: 9
Thanked 0 Times in 0 Posts
adi2011 is on a distinguished road
Re: How to make control when user clicks on Exit button of Form to warn user about...

Hello,

It is for adding new records and your post helped a lot!

Thanks man!

Happy hollydays and all the best.
Adi

adi2011 is offline   Reply With Quote
Reply

Thread Tools
Display Modes Rate This Thread
Rate This Thread:

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
trying to warn data entry user of a particularly odd error joe789 Forms 1 11-04-2011 08:33 AM
Warn user if a field is empty at data entry gear Forms 2 07-13-2008 10:15 PM
Trying to replace invalid keyed text and also warn the user ghudson Excel 8 03-21-2008 01:11 PM
warn a user to enter data in parent form pablavo Modules & VBA 5 11-09-2007 03:05 AM
How to keep a form on focus until user clicks on a cmd button annl Forms 1 03-20-2003 02:46 PM




All times are GMT -8. The time now is 12:31 PM.


Microsoft Access Help
General
Tables
Queries
Forms
Reports
Macros
Modules & VBA
Theory & Practice
Access FAQs
Code Repository
Sample Databases
Video Tutorials

Featured Forum post


Sponsored Links


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
(c) copyright 2017 Access World