Results 1 to 5 of 5
  1. #1
    charly.csh is offline Competent Performer
    Windows 8 Access 2007
    Join Date
    Nov 2014
    Posts
    186

    Dates Format from Code

    Hello all,



    Do you now how change the format of the dates from code?

    I have a textbox called "Datetxt" and when the form is load, it automatically load the date today, however I would like to show date and time

    How can I do this?

    Private Sub Form_Load()
    On Error GoTo err_trap
    GetDomains
    Exit Sub

    Me.Datetxt = Date



    err_trap:
    MsgBox ("Error: " & Err.Number & vbCrLf & Err.Description)
    Exit Sub


    End Sub




    Thanks in advance for the help!!!!

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,772
    Use Now() instead of Date() to capture full date and time value.

    Is the textbox Format property set to allow display of time parts? Don't set any formatting and the full value will display.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows 8 Access 2013
    Join Date
    Aug 2013
    Posts
    7,862
    Without any formatting, you can get the current date and time using
    Me.Datetxt = Now

    The easiest way to format would be to use the properties of the textbox control named Datetxt. I would use the Property Sheet in Design View of your form to format the textbox.

  4. #4
    charly.csh is offline Competent Performer
    Windows 8 Access 2007
    Join Date
    Nov 2014
    Posts
    186
    Thank you
    it's correct!!!

  5. #5
    charly.csh is offline Competent Performer
    Windows 8 Access 2007
    Join Date
    Nov 2014
    Posts
    186
    Thank you it also works!!!

Please reply to this thread with any new information or opinions.

Similar Threads

  1. Format of SQL Code
    By Lou_Reed in forum Access
    Replies: 2
    Last Post: 08-27-2015, 10:25 AM
  2. Replies: 2
    Last Post: 12-09-2014, 02:14 AM
  3. Replies: 6
    Last Post: 08-09-2014, 10:09 PM
  4. Replies: 4
    Last Post: 08-28-2013, 05:20 PM
  5. Code issue on Format of label
    By Gavroche in forum Reports
    Replies: 2
    Last Post: 09-14-2011, 06:19 AM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums