Results 1 to 4 of 4
  1. #1
    Join Date
    May 2015

    Unanswered: help with gett current time in textbox after a command button is pushed

    Hello I am new to the forums. I used to work with access a while back and when I changed career goals I stopped using it and forgot most of what I knew.

    I don't know if this question has been asked if it has please point me in the right direction. What I am trying to do is when I press a command button I need it to get the current system time and display it hh:mm in a textbox on a form. I have tried googling it but can't seems to locate what I am looking for.

  2. #2
    Join Date
    Nov 2012
    Private Sub Cmd1_Click()
    Me.Text0 = Format(Time, "Short Time")
    End Sub

    Will display current time as hh:mm
    Version: Access 2010

  3. #3
    Join Date
    Jun 2005
    Richmond, Virginia USA
    Provided Answers: 19
    Pis7ftw's code will get you the current time in 24 hr/military time. If you need AM/PM designation, replace "Short Time" with "Medium Time."

    Also, note that if you're going to do any kind of manipulation with this, such as sorting, etc. this, in and of itself, is not a DateTime value; the Format Function always returns a String. To make it a DateTime Field, simply define the Field the Textbox is Bound to as a DateTime Datatype.

    Linq ;0)>
    Hope this helps!

    The problem with making anything that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

  4. #4
    Join Date
    May 2015
    Thanks it works, I have already set the data type date/time when I created the table. Other problem that I am trying to get work is where I have to auto number field that displays a set 3 digit then the auto number and then the current year, and it auto number start over when the year changes. The 3 digit number has to comes from the login table. so it would look like this almost (###)-auto number-YYY. I need to have it do this function in a text box on load of the form and the text box can't be edited.
    Last edited by troney; 05-27-15 at 17:56.

Posting Permissions

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