Results 1 to 11 of 11
  1. #1
    jaffar2000 is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Apr 2012
    Posts
    11

    Conditional required field

    Hi,
    I have a form with the following fields:
    1st - Pick-list field of Status
    2nd- Date Field named ApplyDate.
    I would like to set the ApplyDate as mandatory if the Status= 'open'.
    Also presenting a message to the user would be nice.


    thanks,
    J.

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,652
    I had problems editing my own post, so I'll try again. I would use this technique:

    http://www.baldyweb.com/BeforeUpdate.htm

    You would simply add a test of the status field before testing the date.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    jaffar2000 is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Apr 2012
    Posts
    11
    I tried it but it's not working.
    Any other way I can do it?

  4. #4
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,652
    What exactly did you try? What exactly does "not working" mean?
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  5. #5
    jaffar2000 is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Apr 2012
    Posts
    11
    I tried make is simple first and just enforce the date filled so it won't be empty.
    I applied this code (after customizing it to my fields) on the BeforeUpdate of the form, as explained in the provided link.
    If Len(Me.apply_date & vbNullString) = 0 Then
    MsgBox "You need to fill out the date"
    Cancel = True
    Me.apply_date.SetFocus
    End If


    I don't get any message as should be and the form is updated when moving on to the next record.

  6. #6
    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
    How, exactly, shows as the Field Name in the Control Source Property of the 'Apply Date' Control?

    Linq ;0)>

  7. #7
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,652
    Is the code properly associated with the event?http://www.baldyweb.com/FirstVBA.htmHas anything been updated on the form at the point of the test? The update events only fire if there's something to be "updated".
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  8. #8
    jaffar2000 is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Apr 2012
    Posts
    11
    The field name show as apply_date.
    I put the code in the BeforeUpdate event of the form
    I changed data on the form and still nothing.

    I think the problem is deeper than that:
    I created a new form and added a button with a simple OnClick event to present a message to the user.

    Private Sub present_message_Click()
    MsgBox "You need to fill out the date"
    End Sub


    This is not working at all - no message is presented.

    Any ideas why?

  9. #9
    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
    Does any VBA code run? From you last post it sounds as if the answer is "No!" Code does not run in 2007/2010 unless your database resides in a folder that has been declared a “trusted” location.

    To trust your folder, click:
    1. Office Button (top left)
    2. Access Options (bottom of dialog)
    3. Trust Center (left)
    4. Trust Center Settings (button)
    5. Trusted Locations (left)
    6. Add new location (button)

    Here's a visual for it, courtesy of BTAB Development:

    http://www.btabdevelopment.com/ts/de...aspx?PageId=13

    If that doesn't do it, you might check to see if you have a Missing Reference to Windows Common Controls. I have seen a report of this causing this problem, when moving up from previous versions.

    Linq ;0)>

  10. #10
    jaffar2000 is offline Novice
    Windows 7 32bit Access 2007
    Join Date
    Apr 2012
    Posts
    11
    Oh my god...
    I even didn't know it should be like that.
    Tested it and it is working just fine now.

    Thank you all guys.

    J.

  11. #11
    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
    Glad we could help!

    Good luck with your project!

    Linq ;0)>

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

Similar Threads

  1. User Required Field
    By rlsublime in forum Access
    Replies: 4
    Last Post: 03-14-2012, 02:15 PM
  2. Cancel when there is a required field
    By dougie in forum Forms
    Replies: 3
    Last Post: 03-07-2012, 09:38 AM
  3. Replies: 3
    Last Post: 01-15-2012, 02:46 PM
  4. Save as Draft but mandatory field is not required
    By zuerin in forum Programming
    Replies: 5
    Last Post: 06-30-2011, 01:42 AM
  5. Required Field Help
    By brandonb in forum Access
    Replies: 4
    Last Post: 11-13-2009, 11:18 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