Results 1 to 13 of 13
  1. #1
    ItsATJ is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Jan 2013
    Posts
    11

    Checked Box + Date = Checked box

    I am trying to get a "Certified" check box to check itself based on two pieces of information. If the person has completed Phase1 training (a check box) and if they have been to their alt site within the last year. If both of these are yes, then it should check the "Certified" box. Here is the code I have attached to the "Certified" box that doesn't work:



    Code:
    Private Sub ValidateCert()
      If Me.chk_Phase1.Value = -1 Then
        If Now() - Me.txt_Visit.Value < 365 Then
          Me.chk_Cert.Value = -1
        Else
          Me.chk_Cert.Value = 0
        End If
      Else
        Me.chk_Cert.Value = 0
      End If
    End Sub
    Thanks for helping.

  2. #2
    orange's Avatar
    orange is online now Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,726

  3. #3
    ItsATJ is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Jan 2013
    Posts
    11
    Thanks for the help, but I am unsure how/where I need to use - DateAdd ("d", -365, Date()) - if that is even the correct syntax. All the examples have a date in the final field.

  4. #4
    orange's Avatar
    orange is online now Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,726
    In plain English what is it you are doing? Let's make sure we are talking the same functionality before any programming.

  5. #5
    ItsATJ is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Jan 2013
    Posts
    11
    I have a sheet that tracks the training of my personnel. In order to be a Certified Team Member, they need to accomplish a computer based training once (Phase 1 Training) and they also must visit their relocation site annually for a familiarization tour. (Phase 2 Training).

    So, on my form, I have a check box for Phase 1 Training, a date Field for Phase 2 Training and a check box for Certified. If they accomplish Phase 1 Training and have not done a site visit, then they are not a Certified Team Member and the Certified box would not be checked. If the go to the site, but don't accomplish their Phase 1 Training, then, again the Certified box would not be checked. But, if they have accomplished their Phase 1 Training and they have been to the site within 1 year, then the Certified box would get checked. After 1 year and 1 day, if they don't return to the site, the the Certified box will become unchecked.

    I am not sure if the Certified check box properties is the best place to accomplish this, or if there is a better method. I need to pull reports of the number of Certified people on a regular basis, and if the code is on the form, does that mean that I have to "visit" each person's form to update the Certified status?

  6. #6
    orange's Avatar
    orange is online now Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,726
    Sounds like this is what you're looking for (untested)

    Code:
    Private Sub ValidateCert() 
    If Me.chk_Phase1.Value = -1 Then     
        If (DateDiff,"d", Me.txt_Visit.Value,Now()) < 365 Then    
         Me.chk_Cert.Value = -1    
        Else     
         Me.chk_Cert.Value = 0    
       End If   
    Else  
       Me.chk_Cert.Value = 0  
    End If 
    End Sub

    I would also recommend you use True for the -1 and False for 0. I realize these are equivalent, but to me at least the T/F seem "easier".
    Last edited by orange; 01-11-2013 at 12:53 PM. Reason: formatting

  7. #7
    ItsATJ is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Jan 2013
    Posts
    11
    That worked. Thanks.

  8. #8
    orange's Avatar
    orange is online now Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,726

  9. #9
    ItsATJ is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Jan 2013
    Posts
    11
    Actually, to be accurate, I used:

    Code:
    Private Sub ValidateCert()
      If Me.chk_Phase1.Value = -1 Then
        If DateDiff ("d", Me.txt_Visit.Value, Now()) < 365 Then
          Me.chk_Cert.Value = -1
            Else
          Me.chk_Cert.Value = 0
        End If
      Else
        Me.chk_Cert.Value = 0
      End If
    End Sub
    The open parentheses was in the wrong place. Again, Thanks for all your help.

  10. #10
    ItsATJ is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Jan 2013
    Posts
    11
    After using the code for half a year, I have run into a problem.

    When the Site Visit date goes beyond 1 year, the Certified check box won't become unchecked without manual intervention. (I have been unchecking, then rechecking the Phase I check box to force the update.) Is there a way to get Access to "monitor" the two fields and if the date drifts out of the 1 year window, it will uncheck the Certified box automatically? Perhaps there's a macro that can be activated to force an update.

    Thanks for any assistance

  11. #11
    ItsATJ is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Jan 2013
    Posts
    11
    Bump. Any thoughts?

  12. #12
    orange's Avatar
    orange is online now Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,726

  13. #13
    ItsATJ is offline Novice
    Windows 7 64bit Access 2007
    Join Date
    Jan 2013
    Posts
    11
    I have a sheet that tracks the training of my personnel. In order to be a Certified Team Member, they need to accomplish a computer based training once (Phase 1 Training) and they also must visit their relocation site annually for a familiarization tour. (Phase 2 Training).

    So, on my form, I have a check box for Phase 1 Training, a date Field for Phase 2 Training and a check box for Certified. If they accomplish Phase 1 Training but have not done a site visit, then they are not a Certified Team Member and the Certified box would not be checked. If they go to the site, but don't accomplish their Phase 1 Training, then, again the Certified box would not be checked. But, if they have accomplished their Phase 1 Training and they have been to the site within 1 year, then the Certified box would get checked. After 1 year and 1 day, if they don't return to the site, the the Certified box should become unchecked.

    Here is the code we used on the form:

    Code:
    Private Sub ValidateCert()
       If Me.chk_Phase1.Value = -1 Then
         If DateDiff ("d", Me.txt_Visit.Value, Now()) < 365 Then
           Me.chk_Cert.Value = -1
             Else
           Me.chk_Cert.Value = 0
         End If
       Else
         Me.chk_Cert.Value = 0
       End If
     End Sub
    The code that is listed above will run when either of the fields are updated, however, if the date of site visit drifts outside of the one year window, the Certified box remains checked. I have no code in place to verify that a person remains Certified. When I pull the report of all the non-certified personnel , it will not list people who are no longer certified due to a site visit in excess of one year. I am looking for some method to have access re-certify each person's certification daily, either automatically or by manually prompting it by pushing a button.
    Last edited by ItsATJ; 09-03-2013 at 01:27 PM. Reason: Grammer errors were corrected.

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

Similar Threads

  1. VBA for testing if checkbox is checked
    By rhewitt in forum Programming
    Replies: 0
    Last Post: 09-26-2012, 07:11 AM
  2. Display Text Only if Checkbox is Checked
    By Rick5150 in forum Forms
    Replies: 2
    Last Post: 09-16-2012, 09:19 AM
  3. If checkbox is checked, add X to a current value
    By INeedAboutTreeFiddy in forum Programming
    Replies: 4
    Last Post: 05-30-2012, 08:17 AM
  4. Replies: 22
    Last Post: 11-14-2011, 10:29 AM
  5. Counting only 'checked' Yes/No fields on a
    By pwdpwd in forum Programming
    Replies: 9
    Last Post: 04-14-2011, 09:28 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