Results 1 to 6 of 6
  1. #1
    Join Date
    Nov 2005
    Posts
    20

    Current Date in Text Box How do I?

    Hello,

    How do I get the current date to display in a text box named "date" I have bound to the form in Access.

    Do I put the code in the before update procedure? If not which one do I put it in? I just want the date to display on the current record.

    Thanks for your help.


    Ry

  2. #2
    Join Date
    Mar 2003
    Location
    The Bottom of The Barrel
    Posts
    6,102
    Have you checked the help file for Date yet?
    oh yeah... documentation... I have heard of that.

    *** What Do You Want In The MS Access Forum? ***

  3. #3
    Join Date
    Jul 2004
    Location
    Southampton, UK
    Posts
    368
    Quote Originally Posted by benz84
    Hello,

    How do I get the current date to display in a text box named "date" I have bound to the form in Access.

    Do I put the code in the before update procedure? If not which one do I put it in? I just want the date to display on the current record.

    Thanks for your help.

    Ry
    It depends a lot more on what you want to do. If you only want the current date to appear on a new record then put the date function you've chosen to use (from your previous post) into the default value of either the table or the form. Then each time you create a new record the date field will defaul to todays date.

    If you want any record that has just been accessed (i.e. made current), to change then you could use the "on current" event for the form so that every time you navigate to another record the date will change to today (probably not what you want).

    If you want to change the date to reflect when a record was last edited then the forms "after update" might suit (although you probably won't seee the changes until to go into the record again). "before update" should be fine also. Read the help on these as there are subtle differences. Also take a look at "before insert".

    As I say, it depends on what you want to cause the trigger.

    If you click next to the event in the properties screen and then press the help (F1) key you will get a good (but not perfect !) description of what each event does i.e. how it is triggered.

    hth
    Chris

  4. #4
    Join Date
    Dec 2005
    Location
    Arnhem, Gld, NL
    Posts
    21
    textbox.value = Date()

    that should do the trick, you can put that line in the form_load event.
    If you do not use VB, put 'Date()' (without quotes) in the property field called 'defaultvalue' when you open the form, the date apears in the box..

    if you want to dispay the date from a table, a value in a table i mean,
    put the name of the datecolumn in the ControlSource property

  5. #5
    Join Date
    Aug 2002
    Location
    Melbourne, Australia
    Posts
    111
    You say the text box is bound to the form, I take it you mean bound to the data source (e.g. table) .

    Open the table in design view select your "Date" field, now down the bottom you will see the word Default put Date (), Select your format. Thats it.

    When you create fields in access tables you should never use reserved words (Date is one of them).Call it myDate or something else but not date.

    If you stay with the name date you will have problems.
    Regards,



    John A

  6. #6
    Join Date
    Feb 2006
    Posts
    56
    have a label control on the form. on the form properties section, set the form timer to 1000. post the following in the form event timer

    Private Sub Form_Timer()
    'set the caption value to now(). The timer is set to 1000 so the form will display a clock with date & time
    Me.Label1.Caption = Now()
    End Sub


    hope this helps.

    John

Posting Permissions

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