Results 1 to 5 of 5
  1. #1
    Ekhart is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Jun 2016
    Posts
    80

    t to todays date


    Is there a way to have it so if someone simply inputs a t in a 'Short Date' field it will populate with todays date? I know they can open the calendar and select the Today option but some people tab through and switching to a mouse slows things down.

  2. #2
    burt1215 is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Jun 2016
    Posts
    34
    Here's how I would do it.
    Instead of a t, I would just leave it blank, that way you tab through and don't even have to press a letter. (Is there any instance where you would tab through, leave it blank, and not want today's date?)

    So whatever the field is, let's say it's a text box name txtDate, you're gonna want to set the on lost focus property event to some code.
    Maybe something like this.

    Code:
    Private Sub txtDate_LostFocus()
        If IsNull(Me.txtDate) Then
            Me.txtDate = Date
        End If
    End Sub
    You could also set it to "t" but you will have to change the validation to just general text, since t is not a date.
    It would look like this

    Code:
    Private Sub txtDate_LostFocus()
        If Me.txtDate = "t" Then
            Me.txtDate = Date
        End If
    End Sub

  3. #3
    ssanfu is offline Master of Nothing
    Windows XP Access 2010 32bit
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    There is a shortcut to enter just today's date. Click into a text box, then press ctl + ; .
    To enter the time, press ctl + shift + ; .

    To enter the date and time, press ctl + ; , a space then ctl + shift + ;

  4. #4
    CJ_London is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,397
    or just set the default to Date() (which is todays date)

  5. #5
    burt1215 is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Jun 2016
    Posts
    34
    I misspoke.
    It's not IsNull that you're testing.
    You have to test for
    Code:
    Me.txtDate = ""
    I'm not really sure why, but that's what works.
    Also, these other ideas are pretty good too. Haha.

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

Similar Threads

  1. Replies: 3
    Last Post: 06-13-2014, 09:16 PM
  2. Replies: 1
    Last Post: 03-19-2012, 04:29 PM
  3. Replies: 1
    Last Post: 12-12-2011, 06:32 AM
  4. Update with Todays Date on Open
    By anoob in forum Forms
    Replies: 5
    Last Post: 03-08-2011, 02:00 PM
  5. Adding todays date
    By EDEd in forum Forms
    Replies: 2
    Last Post: 10-08-2010, 06:27 PM

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