Update date automatically

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • prabhus
    New Member
    • Mar 2014
    • 2

    Update date automatically

    In my Access form, users update 11 check boxs when their work is completed, when this 11 boxed checked then the 12th check box will check automatically using after update & updatelast event.
    Now i have added the 6 the column with date completed, here i want the date to be updated automatically when the 5th column is checked automatically. how to do it?
    Breaking my head

    Code:
    Private Sub Updatelast()
    Me.Check110 = Me.Check88 And Me.Check90 And Me.Check92 And Me.Check94 And Me.Check96 And Me.Check98 And Me.Check100 And Me.Check102 And Me.Check104 And Me.Check106 And Me.Check108
    End Sub
    this is my code. I have used afterupdate in all the checks from 88 to 108, when the user checks all the boxes, Check 110 will update automatically using Update last. Until this its perfectly working. Until the user check all the boxes, check 110 will not get checked.
    User can't update check110 manually, its locked
    Now i have added another field and when check110 updated automatically, i want the date to display, if the check 110 deselected, the date should be removed. is it possible?

    i tried the below code, but not working
    but i think the event i have selected is wrong, i dont know what event to use.

    Code:
    Private Sub Check110_Click()
    If (Me!Check110 = "Yes" Or "True" Or "-1") Then
    Me!Text125 = Date
    Else
    Me!Text125 = Null
    End If
    End Sub
    Any help, highly appreciated!!!
    Last edited by zmbd; Mar 24 '14, 10:01 PM. Reason: [Z{Please use the [CODE/] button to format posted script and formated text - Please read the FAQ}]
  • zmbd
    Recognized Expert Moderator Expert
    • Mar 2012
    • 5501

    #2
    I'll give you a hint here

    Try this on a new form
    Add just the check box named check2
    and just the text box named text0

    Code:
    Option Compare Database
    Option Explicit
    
    Private Sub Check2_Click()
        If Me.Check2 Then
            Me.Text0.Value = Date
        Else
            Me.Text0.Value = Null
        End If
    End Sub
    See the two differences between your code and mine?

    Check boxes are typically true/false by default and can be set to triple state true/false/null in the properties.

    perhaps the value isn't absolutely needed for the textbox; however, I tend to use it.

    Comment

    • prabhus
      New Member
      • Mar 2014
      • 2

      #3
      Hi,

      Thank you for your idea.

      But i can't use the onclick event, because check110 not updated by user, based on the other checkboxes it will update automatically.
      This is were i got struck.

      Comment

      • zmbd
        Recognized Expert Moderator Expert
        • Mar 2012
        • 5501

        #4
        You'll have to see if the onchange event will work as none of the others will trigger when the control is set via VBA until the record changes or the user interacts with the control.
        Not sure why you are doing this with this control... seems awfully bashed-togeither.

        Comment

        Working...