Results 1 to 3 of 3
  1. #1
    4 Star Lounger
    Join Date
    Apr 2001
    Location
    Guatemala City
    Posts
    515
    Thanks
    0
    Thanked 0 Times in 0 Posts

    Changing the "required" property according to value in another field

    I would like to set the "required" property in Field One (Text) of an Access table to True if Field Two (Date) has a value. Any hints to get me started, please?

  2. #2
    Super Moderator RetiredGeek's Avatar
    Join Date
    Mar 2004
    Location
    Manning, South Carolina
    Posts
    9,436
    Thanks
    372
    Thanked 1,457 Times in 1,326 Posts
    G,

    You could use something like this in the date field (text4) in the example.
    Code:
    Option Compare Database
    Option Explicit
    
    Private Sub Text4_LostFocus()
        If (Not IsNull(Me.Text4.Value)) And _
           IsNull(Me.Text0.Value) Then
             MsgBox "Field1 is Required", _
                    vbOKOnly + vbCritical, _
                    "Error: Required data missing"
           Me.Text0.SetFocus
        End If
         
        
    End Sub
    You would use similar code Lost_Focus event in Field1. HTH
    AccessReqField.JPG

    Update: I forgot to mention that you could do date specific testing instead of just checking for an empty field.
    Last edited by RetiredGeek; 2013-07-15 at 15:33. Reason: Additional Information
    May the Forces of good computing be with you!

    RG

    PowerShell & VBA Rule!

    My Systems: Desktop Specs
    Laptop Specs

  3. #3
    4 Star Lounger
    Join Date
    Apr 2001
    Location
    Guatemala City
    Posts
    515
    Thanks
    0
    Thanked 0 Times in 0 Posts
    Perfect! My problem is resolved, as usual.

    Thank you.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •