My Assistant
![]() ![]() |
|
|
Aug 5 2003, 03:20 AM
Post
#1
|
|
|
UtterAccess Member Posts: 20 From: UK |
Hi
I have designed a form template in Excel that users will fill out. Is there any way to specify certain fields as mandatory and prompt the user with a warning if they try to save or close the document without filling in these fields? Ideally, I would like a situation where the form cannot be closed unless certain fields are filled in and for all the other (mandatory) fields, Excel shows up a warning... Thanks Krishna |
|
|
|
Aug 5 2003, 05:11 AM
Post
#2
|
|
|
UtterAccess Ruler Posts: 1,585 From: Oxford UK |
Try something like this:-
Sub Auto_Close() If Sheets(3).Range("A1") = "" Then MsgBox "No" Exit Sub End If End Sub |
|
|
|
Aug 5 2003, 08:01 AM
Post
#3
|
|
|
UtterAccess Member Posts: 20 From: UK |
Cheers Paul.
The above code prompts the user but still lets him close the file wihtout populating the field. What would I need to add to this to make the system force the user to populate the field before it lets him close the file? |
|
|
|
Aug 5 2003, 08:44 AM
Post
#4
|
|
|
UtterAccess Ruler Posts: 1,585 From: Oxford UK |
I used the wrong event.
The Cancel = True bit keeps the book open. In the VBE window under 'This Workbook' use this kind of code, you can also set cell properties so they appear differently ( red border or something) Private Sub Workbook_BeforeClose(Cancel As Boolean) If Sheets(3).Range("A1") = "" Then MsgBox "No" Cancel = True End Sub |
|
|
|
![]() ![]() |
|
Go to Top · Lo-Fi Version | Time is now: 24th May 2013 - 09:32 AM |