Results 1 to 10 of 10
  1. #1
    johnseito is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Aug 2013
    Posts
    419

    VBA -- Me.bidTimeCombo = Now() to only Time

    How can I make this code in VBA to become only time, rather than date and time as it is now.

    Me.bidTimeCombo = Now()

  2. #2
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,870

  3. #3
    johnseito is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Aug 2013
    Posts
    419
    Ok, do you know how that could be done using SQL.

    I tried this:
    Code:
     
    SELECT time ()  as t
    and it say undefined function time in expression.

  4. #4
    johnseito is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Aug 2013
    Posts
    419
    I put this in my VBA access,

    Code:
       Me.bidTimeCombo = Time()
    and I get compile error: Can't find project or library.

    It can only work when it is like this,

    Code:
       Me.bidTimeCombo = Now()

  5. #5
    johnseito is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Aug 2013
    Posts
    419

  6. #6
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    AFAIK, Time() is not an intrinsic function. Use Format(). The result will be a string. Why not just save the full date/time? Can always manipulate the value later.
    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.

  7. #7
    orange's Avatar
    orange is offline Moderator
    Windows XP Access 2003
    Join Date
    Sep 2009
    Location
    Ottawa, Ontario, Canada; West Palm Beach FL
    Posts
    16,870
    ?time()
    6:24:18 PM

    works for me with A2010

  8. #8
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,770
    I am trying Access 2010 and doesn't work. What am I missing? Year(), Month(), Day(), Hour(), Second() all work. Oh, wait, Time() doesn't have an argument. Oh wow!
    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.

  9. #9
    johnseito is offline Competent Performer
    Windows 7 64bit Access 2010 64bit
    Join Date
    Aug 2013
    Posts
    419
    Quote Originally Posted by June7 View Post
    AFAIK, Time() is not an intrinsic function. Use Format(). The result will be a string. Why not just save the full date/time? Can always manipulate the value later.
    Yes I am trying to use the now() and manipulate it, but then I have to cast it back to time after manipulating the dates/time combo. What is AFAIK?

  10. #10
    ItsMe's Avatar
    ItsMe is offline Sometimes Helpful
    Windows XP Access 2003
    Join Date
    Aug 2013
    Posts
    7,862
    As far as I know AFAIK is an acronym

    Dim strTime As String
    strTime = Format(Now(), "yyyymmdd_hh:mm:ss")
    Me.txtTest.Value = Right(strTime, 8)

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

Similar Threads

  1. Replies: 42
    Last Post: 03-01-2013, 06:58 AM
  2. Replies: 1
    Last Post: 08-14-2012, 03:22 AM
  3. Replies: 1
    Last Post: 02-28-2012, 09:16 PM
  4. Replies: 7
    Last Post: 08-04-2011, 07:49 PM
  5. Replies: 12
    Last Post: 02-22-2011, 03:39 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