Results 1 to 8 of 8
  1. #1
    DubCap01 is offline Competent Performer
    Windows 7 64bit Access 2013 64bit
    Join Date
    Sep 2014
    Location
    Dubbo, Australia
    Posts
    104

    Adding today's date using just the letter T

    Hi all,



    I know the answer is here on the forum, but searches are revealing nothing like the answer I need.

    I want to type the letter t or T into a date field, and then the VBA kicks in and provides "today's" date in dd/mm/yy format.

    Could anyone help with reminding me what that VBA syntax is?

    thanks in anticipation

    Pete

  2. #2
    isladogs's Avatar
    isladogs is offline MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    5,954
    If its a bound control, the problem you have is trying to type text (T) into a textbox formatted for dates.
    If its unbound and unformatted, add code to the control after update event.
    Code:
    if me.textboxname="T" Then Me.textboxname=Date
    Personally I would just use the date picker which defaults to today's date...or have a today button to set the field to the current date
    Colin, Access MVP, Website, email
    The more I learn, the more I know I don't know. When I don't know, I keep quiet!
    If I don't know that I don't know, I don't know whether to answer

  3. #3
    Missinglinq's Avatar
    Missinglinq is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    May 2012
    Location
    Richmond (Virginia, not North Yorkshire!)
    Posts
    3,016
    Or don't make the user do anything...simply set the Default Value of the Control to

    =Format(Date(),"dd/mm/yy")

    It can then be changed, if need be.

    Linq ;0)>
    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

  4. #4
    Join Date
    Apr 2017
    Posts
    1,673
    Ctrl+ShIft+comma inserts current date into field or control in Excel or Access!

  5. #5
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,397
    or use the control double click event

    mytextbox=date()

  6. #6
    rpeare is offline VIP
    Windows XP Access 2003
    Join Date
    Jul 2011
    Posts
    5,442
    why not just have an 'on exit' event to fill the date field with today's date if it's blank, otherwise do nothing.

  7. #7
    isladogs's Avatar
    isladogs is offline MVP / VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jan 2014
    Location
    Somerset, UK
    Posts
    5,954
    OK that's 5 solutions. Hopefully the OP can make use of one of them.
    I would either use the date picker or the default value as suggested by Linq
    Colin, Access MVP, Website, email
    The more I learn, the more I know I don't know. When I don't know, I keep quiet!
    If I don't know that I don't know, I don't know whether to answer

  8. #8
    June7's Avatar
    June7 is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,820
    And if you haven't already seen, review http://allenbrowne.com/ser-36.html
    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.

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

Similar Threads

  1. Replies: 2
    Last Post: 03-12-2018, 08:16 AM
  2. Adding a letter after a date
    By Sturgis76 in forum Forms
    Replies: 1
    Last Post: 04-05-2017, 06:19 PM
  3. Replies: 1
    Last Post: 11-26-2013, 09:25 AM
  4. Replies: 5
    Last Post: 10-12-2012, 11:00 AM
  5. Replies: 12
    Last Post: 04-26-2012, 04:01 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