Results 1 to 6 of 6
  1. #1
    harry1987 is offline Novice
    Windows 7 64bit Access 2013
    Join Date
    Mar 2015
    Posts
    5

    On close form button check if required fields are answered

    I have a set of questions with yes/no options.



    How do I check if these are answered when close button is clicked in the form.

    Thanks.

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    What does answered for a yes/no field mean? A yes/no field is either True or False, has to be one or the other. The default unless specified otherwise is False. Leaving the default could be a valid response. So how should one know if the field was not answered?
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    harry1987 is offline Novice
    Windows 7 64bit Access 2013
    Join Date
    Mar 2015
    Posts
    5
    Actually its a form with questions,and the end user can only access form and print it as is,so they should select a button before closing.

  4. #4
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    I don't understand. That does not change my comment.

    Select a button for what?
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  5. #5
    Missinglinq's Avatar
    Missinglinq is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    May 2012
    Location
    Richmond (Virginia, not North Yorkshire!)
    Posts
    3,018
    June7's comment goes right to the heart of the problem...if the user doesn't tick the Checkbox, it already has a value, so doing validation to ensure that the Control is populated is useless...because it is populated, by default!

    To be able to verify that a choice has been made, instead of a Checkbox, you need to use a Combobox with two values, Yes and No. If no choice is made, the Combobox will be Null, which you can test for.

    Alternatively, you could use an Option Group with two Checkboxes or Radio Buttons, one for 'yes' and one for 'no,' and validate the same way.

    The 'close form' button should just do that...close the Form; the validation code would then go in the Form_BeforeUpdate event, where the update can be cancelled if the required Controls aren't populated..

    Linq ;0)>
    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

  6. #6
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    Linq, I think a combobox and option group will also show No/False as default value if they are bound to the field, at least does in my test, so that still will not resolve the issue.

    Probably need to use text or number instead of yes/no type field.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. If number then set close button on form to false
    By Ruegen in forum Programming
    Replies: 6
    Last Post: 10-20-2013, 09:09 PM
  2. Close Form button not working
    By RedGoneWILD in forum Forms
    Replies: 2
    Last Post: 06-25-2012, 07:02 AM
  3. Disable master form close button
    By Carpy01 in forum Forms
    Replies: 3
    Last Post: 12-31-2010, 05:41 PM
  4. Required Fields in a Form
    By Alaska1 in forum Access
    Replies: 3
    Last Post: 12-23-2010, 01:41 PM
  5. Replies: 4
    Last Post: 09-10-2009, 03:09 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums