Results 1 to 5 of 5
  1. #1
    Alphavk is offline Novice
    Windows 10 Access 2007
    Join Date
    Oct 2017
    Posts
    7

    Validation in MS access 2010

    Hi All,

    I have a table in which there is a field called "Status" which is value list field, values are "Open", "Closed", "Pending"

    In the same table there is a field called "Date Closed".

    I want to make a date entry mandatory to the "Date closed" field if the field named Status is selected with "Closed"


    with a pop up message to the user saying that "closed date missing"

    Thanks to all in advance for your kind response.

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,521
    I have a 'save' button (they dont know access saves automatically)
    and a flag in Unload event to validate

    usage:
    if IsValidForm() then ' allow to close form


    Code:
    Private Function IsValidForm() As Boolean
    Dim vMsg
    Select Case True
       Case [Status] = "Closed" and IsNull(txtCloseDate)
          vMsg = "Closed Date field missing"
    
    
       Case IsNull(cboUser)
          vMsg = "Teacher name is missing"
    
    
       Case IsNull(cboSubj)
          vMsg = "Subject field is missing"
    End Select
    If vMsg <> "" Then MsgBox vMsg, vbCritical, "Required Field"
    IsValidForm = vMsg = ""
    End Function

  3. #3
    ssanfu is offline Master of Nothing
    Windows 7 32bit Access 2010 32bit
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    You could use the form BeforeUpdate event to check the status and the "Date Closed" controls. If Status = "Closed" and "Date Closed" is not a date or is NULL, display a message and cancel to update.

    BTW, should NOT have spaces in object names. "DateClosed" or "Date_Closed" are better.
    This includes field, form, query, report and Module names.

  4. #4
    Alphavk is offline Novice
    Windows 10 Access 2007
    Join Date
    Oct 2017
    Posts
    7
    Thanks for the replies.

    I tried it but not working, showing some error

    Can you explain how to do based on the attached

    Thanks for your support

    Alpha..
    Attached Thumbnails Attached Thumbnails Untitled.png  

  5. #5
    orange's Avatar
    orange is offline Moderator
    Windows 10 Access 2010 32bit
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,716
    I tried it but not working, showing some error
    Kindly show us the error message and number

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

Similar Threads

  1. Replies: 5
    Last Post: 01-07-2016, 12:49 PM
  2. Replies: 2
    Last Post: 06-16-2015, 03:52 AM
  3. Replies: 6
    Last Post: 07-07-2014, 09:13 AM
  4. Access 2010 Checkbox & Validation Rules
    By mrmims in forum Access
    Replies: 1
    Last Post: 04-29-2014, 08:52 AM
  5. Replies: 0
    Last Post: 07-31-2012, 12:25 PM

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