Results 1 to 6 of 6
  1. #1
    Join Date
    Sep 2003
    Location
    netherlands
    Posts
    25

    Red face Unanswered: button to fill in date

    hi
    what i want to do is press a button and this will result in filling in today's
    date in a table
    i think it is very simple to to this but i'm still very new with this
    i have searched the data base for this but can't find anything
    thanx for your help

  2. #2
    Join Date
    Feb 2004
    Posts
    142
    A Code based solution would be to use the button's onClick event on a bound form the code would be

    Private sub cmdButton_OnClick()
    me!ControlName = Date()
    end sub

    or if the records in the table only need today's date added to a record on creation then you can simply set that field's default value =Date()
    KC

  3. #3
    Join Date
    Feb 2004
    Location
    CT,USA
    Posts
    250

    Wink

    Try your tool box more controls .... Calendar 8.0 might help.

  4. #4
    Join Date
    Sep 2003
    Location
    MI
    Posts
    3,713

    Re: button to fill in date

    Originally posted by max_down
    hi
    what i want to do is press a button and this will result in filling in today's
    date in a table
    i think it is very simple to to this but i'm still very new with this
    i have searched the data base for this but can't find anything
    thanx for your help
    Private Sub SomeButton_Click()
    SQLString="UPDATE SomeTable SET SomeDate=Date WHERE (SomeCondition=True);"
    DoCmd.RunSQL SQLString

    End Sub

  5. #5
    Join Date
    Sep 2003
    Location
    netherlands
    Posts
    25

    Thumbs up

    thanx all for your help
    will try them all

    regards
    max

  6. #6
    Join Date
    Jun 2003
    Location
    Ohio
    Posts
    12,592
    Provided Answers: 1
    "Private Sub SomeButton_Click()
    SQLString="UPDATE SomeTable SET SomeDate=Date WHERE (SomeCondition=True);"
    DoCmd.RunSQL SQLString
    End Sub"

    If you aren't carefull with your WHERE clause, this type of code could end up updating every record in your database, not just the current record.

    I've used AZ KC's method with success many times.
    If it's not practically useful, then it's practically useless.

    blindman
    www.chess.com: "sqlblindman"
    www.LobsterShot.blogspot.com

Posting Permissions

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