Tick box

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • paul.bentley@networkrail.co.uk

    Tick box

    I am trying to get a "Date entered" box to automatically fill when a
    tick box = true, without success so its over to the experts for some
    much needed help
    Thanks in advance
  • Allen Browne

    #2
    Re: Tick box

    So you want the field named "Date Entered" to fill in with todays date and
    time, when the user checks a yes/no field named (say) IsPicked?

    Use the AfterUpdate event procedure of the check box in your form. Something
    like this:

    Private Sub IsPicked_AfterU pdate()
    If Me.IsPicked.Val ue Then
    Me.[Date Entered] = Now()
    Else
    Me.[Date Entered] = Null
    End If
    End Sub

    Use Date() instead of Now() if you only want the date (not the time as
    well.)

    --
    Allen Browne - Microsoft MVP. Perth, Western Australia
    Tips for Access users - http://allenbrowne.com/tips.html
    Reply to group, rather than allenbrowne at mvps dot org.

    <paul.bentley@n etworkrail.co.u kwrote in message
    news:722b0a15-7160-4738-8e70-2778ad65afb9@u3 6g2000prf.googl egroups.com...
    >I am trying to get a "Date entered" box to automatically fill when a
    tick box = true, without success so its over to the experts for some
    much needed help
    Thanks in advance

    Comment

    • paul.bentley@networkrail.co.uk

      #3
      Re: Tick box

      On 3 Apr, 12:37, paul.bent...@ne tworkrail.co.uk wrote:
      I am trying to get a "Date entered" box to automatically fill when a
      tick box = true, without success so its over to the experts for some
      much needed help
      Thanks in advance
      Additionally I have used the following
      Private Sub Statement_Sent_ AfterUpdate
      If Me![Statement Sent] = True Then
      Me![Statement Sent Date] = Date
      Else
      Me![Statement Sent Date] = Null
      End If
      End Sub


      Which works but i have 143 records and even if i only tick on of the
      yes/no boxes All of the Date entered boxes i have fill in, I want the
      system to just date the one record for which the tick box refers.

      Comment

      • Allen Browne

        #4
        Re: Tick box

        If you want to make this change for all your existing records as well, use
        an Update query.

        1. Create a query using this table.

        2. In the Criteria under the [Statement Sent field], enter:
        True

        3. In the Criteria under the [Statement Sent Date], enter:
        Is Null

        4. Change it to an Update query (Update on Query menu.)

        5. In the Update row under [Statement Sent Date], enter:
        Date()

        6. Run the query.
        The relevant rows will now contain today's date.

        --
        Allen Browne - Microsoft MVP. Perth, Western Australia
        Tips for Access users - http://allenbrowne.com/tips.html
        Reply to group, rather than allenbrowne at mvps dot org.

        <paul.bentley@n etworkrail.co.u kwrote in message
        news:2b4b7589-97e5-4cd8-8042-267e93e10fca@d2 1g2000prf.googl egroups.com...
        On 3 Apr, 12:37, paul.bent...@ne tworkrail.co.uk wrote:
        >I am trying to get a "Date entered" box to automatically fill when a
        >tick box = true, without success so its over to the experts for some
        >much needed help
        >Thanks in advance
        >
        Additionally I have used the following
        Private Sub Statement_Sent_ AfterUpdate
        If Me![Statement Sent] = True Then
        Me![Statement Sent Date] = Date
        Else
        Me![Statement Sent Date] = Null
        End If
        End Sub
        >
        >
        Which works but i have 143 records and even if i only tick on of the
        yes/no boxes All of the Date entered boxes i have fill in, I want the
        system to just date the one record for which the tick box refers.

        Comment

        • Salad

          #5
          Re: Tick box

          paul.bentley@ne tworkrail.co.uk wrote:
          On 3 Apr, 12:37, paul.bent...@ne tworkrail.co.uk wrote:
          >
          >>I am trying to get a "Date entered" box to automatically fill when a
          >>tick box = true, without success so its over to the experts for some
          >>much needed help
          >>Thanks in advance
          >
          >
          Additionally I have used the following
          Private Sub Statement_Sent_ AfterUpdate
          If Me![Statement Sent] = True Then
          Me![Statement Sent Date] = Date
          Else
          Me![Statement Sent Date] = Null
          End If
          End Sub
          >
          >
          Which works but i have 143 records and even if i only tick on of the
          yes/no boxes All of the Date entered boxes i have fill in, I want the
          system to just date the one record for which the tick box refers.
          If this is a form, this code will be pretty close. I simply add "Date"
          after the fieldname/textbox

          Private Sub Tick_AfterUpdat e()
          Dim ctl As Control
          Dim frm As Form
          For Each ctl In Me.Controls
          Select Case ctl.ControlType
          Case acCheckBox
          If ctl.name <"Tick" Then
          'space then date to end of checkbox name
          Me(ctlName & " Date").Value = IIf(Me.Tick, Date, Null)
          End If
          Case Else
          End Select
          Next
          End Sub

          Ice Cube

          Comment

          Working...