How to make control when user clicks on Exit button of Form to warn user about...? (1 Viewer)

adi2011

Registered User.
Local time
Yesterday, 20:46
Joined
May 1, 2011
Messages
60
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
 

AccessMSSQL

Seasoned Programmer-ette
Local time
Yesterday, 20:46
Joined
May 3, 2012
Messages
636
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
 

adi2011

Registered User.
Local time
Yesterday, 20:46
Joined
May 1, 2011
Messages
60
Hello,

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

Thanks man!

Happy hollydays and all the best.
Adi
 

Users who are viewing this thread

Top Bottom