Results 1 to 8 of 8
  1. #1
    mainerain is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Sep 2018
    Location
    Maine, USA
    Posts
    146

    Medium Time in unbound text box


    I am trying to have the time display on a form. I have done this in another db that worked fine. I duplicated the same scenario and attributes (that I can tell) but it won't work on new db. I am beside myself. I figured it out once before but I am stuck now. Any suggestions? Thanks.

  2. #2
    Join Date
    Jan 2017
    Location
    Swansea,South Wales,UK
    Posts
    6,556
    Copy the control from the db where you say it works?
    Please use # icon on toolbar when posting code snippets.
    Cross Posting: https://www.excelguru.ca/content.php?184
    Debugging Access: https://www.youtube.com/results?sear...bug+access+vba

  3. #3
    CJ_London is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,931
    perhaps your control needs a controlsource of '=time()' and formatted as medium time. If it is any more complicated than that you need to tell us an awful lot more

  4. #4
    moke123's Avatar
    moke123 is offline Me.Dirty=True
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2012
    Location
    Ma.
    Posts
    1,879
    what time? Time from a field in a table or the current time?

    Have you tried the Time()?
    Code:
    ?format(time(),"medium time")
    If this helped, please click the star * at the bottom left and add to my reputation- Thanks

  5. #5
    mainerain is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Sep 2018
    Location
    Maine, USA
    Posts
    146
    Quote Originally Posted by Ajax View Post
    perhaps your control needs a controlsource of '=time()' and formatted as medium time. If it is any more complicated than that you need to tell us an awful lot more
    That does show a time but it doesn't continue to update.

    I came back after a long break and found what I had done. Under the form Event tab I set the time interval to 1000 and the On Timer event I referenced the name of the text box like this: tbxTime = Now

  6. #6
    CJ_London is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,931
    so you wanted the current time to display in an unbound control?

    by why update every second when you are only displaying hours and minutes?

    suggest include a bit of code in your timer event to reset the interval to 60000 when number of seconds=0

    Code:
    Private Sub Form_Timer()
    
    
        TxtTime = Now()
        If Second(Now()) = 0 Then TimerInterval = 60000
    
    End Sub

  7. #7
    mainerain is offline Competent Performer
    Windows 10 Access 2016
    Join Date
    Sep 2018
    Location
    Maine, USA
    Posts
    146
    I don't fully understand how the On Timer and Time Interval work. I get the same result either way. Is your way better in some way? I tried putting the 60000 in place of my 1000 for the Time Interval and with just tbxTime = now in vba but it didn't work. Any explanation is appreciated. Thanks.

  8. #8
    CJ_London is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,931
    the code I provided works for me - just need to put the name of your control

    timer events cause other code to pause whilst it runs - it may be you are not running other code which would be affected by this, but once a minute is better than 60 times a minute

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

Similar Threads

  1. Replies: 4
    Last Post: 10-15-2020, 10:13 AM
  2. Replies: 1
    Last Post: 08-24-2018, 02:08 PM
  3. Replies: 1
    Last Post: 04-24-2018, 07:00 AM
  4. Replies: 3
    Last Post: 12-30-2016, 10:27 AM
  5. Unbound text box real time updates
    By DB2010MN26 in forum Forms
    Replies: 14
    Last Post: 12-11-2011, 02:23 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