Insert current date using checkbox

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • jomats
    New Member
    • Aug 2007
    • 1

    #1

    Insert current date using checkbox

    I am a newbie trying to learn Access from several books. I'm sure this is an easy one to answer..for someone, not me. Is it possible to insert a checkbox on a form which, when checked, inserts the current date into one of the fields in the form?

    In Design View I put a checkbox alongside a field (Honorarium1).
    I clicked to select it, then in its Properties I typed Honorarium1 as the Control Source.

    When I clicked in the checkbox in form view 12/29/1899 appeared in the Honorarium field. huh??? I tried changing the Control Source to another field in the form and nothing came up when i tested it. I checked my underlying table and didn't have that odd date anywhere in in the table.

    I'm also wondering if I can place checkboxes next to several other fields on the form as well. The form lists several milestones that occur at different dates and I want to avoid having to type the current date into each of them for each record. Same procedure?

    Thank you. Joan
  • NeoPa
    Recognized Expert Moderator MVP
    • Oct 2006
    • 32669

    #2
    You have (accidentally) posted this question in the Access Articles section. This is NOT an article.
    I'm moving this to the main Access questions forum.

    MODERATOR.

    Comment

    • NeoPa
      Recognized Expert Moderator MVP
      • Oct 2006
      • 32669

      #3
      Originally posted by jomats
      I am a newbie trying to learn Access from several books. I'm sure this is an easy one to answer..for someone, not me. Is it possible to insert a checkbox on a form which, when checked, inserts the current date into one of the fields in the form?

      In Design View I put a checkbox alongside a field (Honorarium1).
      I clicked to select it, then in its Properties I typed Honorarium1 as the Control Source.

      When I clicked in the checkbox in form view 12/29/1899 appeared in the Honorarium field. huh??? I tried changing the Control Source to another field in the form and nothing came up when i tested it. I checked my underlying table and didn't have that odd date anywhere in in the table.

      I'm also wondering if I can place checkboxes next to several other fields on the form as well. The form lists several milestones that occur at different dates and I want to avoid having to type the current date into each of them for each record. Same procedure?

      Thank you. Joan
      You can use a CheckBox if you like, but various other programmable events could also be used. A CheckBox is probably not the most appropriate in the circumstances, as unchecking it later wouldn't make much sense. What about using the Double-Click event of the control you're using to store the date field in? In the event property just have some code to say :
      Code:
      Me.[YourDateControl] = Date()

      Comment

      • missinglinq
        Recognized Expert Specialist
        • Nov 2006
        • 3533

        #4
        NeoPa's suggestion is right on the money! Replacing YourDateField in the following code
        [CODE=vb]Private Sub YourDateField_D blClick(Cancel As Integer)
        Me.YourDateFiel d = Date()
        End Sub
        [/CODE] with the actual name of your date field will allow your users to assign the current date to the field by double-clicking on it. You can repeat this for as many fields as is necessary.

        12/29/1899 is the date Access defaults to, if you will, when a non-date is assigned to a field whose datatype is defined as Date/Time.
        I clicked to select it, then in its Properties I typed Honorarium1 as the Control Source.
        This has assigned a date field Honorarium1 as the Control Source of a checkbox, which has a datatype of Yes/No, which is confusing Access. You need to go back into the Properties box and delete this.

        Welcome to TheScripts, Joan!

        Linq ;0)>

        Comment

        Working...