Adding timer to text box

I have a subform where I am calculating time difference between current time 
and the last update. I have a text box txtTimeDiff with control source 
=ElapsedTimeString([Last Update],Now())

Is it possible to add timer so this text box and time difference can be 
updated every second?

Here is ElapsedTimeString function
Public Function ElapsedTimeString(Date1 As Date, _
                                  Date2 As Date) _
                                  As String

  Dim interval As Double, str As String, days As Variant
  Dim hours As String, Minutes As String, seconds As String

  If IsNull(Date1) = True Or _
    IsNull(Date2) = True Then Exit Function

  interval = Date2 - Date1
  days = Fix(CSng(interval))
  hours = Format(interval, "h")
  Minutes = Format(interval, "n")
  seconds = Format(interval, "s")

' Hours part of the string
  str = str & IIf(hours = "0", "", _
    IIf(hours = "1", hours & " Hour", hours & " Hours"))
  str = str & IIf(hours = "0", "", _
    IIf(Minutes & seconds <> "00", ", ", " "))

' Minutes part of the string
  str = str & IIf(Minutes = "0", "", _
    IIf(Minutes = "1", Minutes & " Minute", _
                  Minutes & " Minutes"))
 str = str & IIf(Minutes = "0", "", _
            IIf(seconds <> "0", ", ", " "))

'Seconds part of the string
  str = str & IIf(seconds = "0", "", _
    IIf(seconds = "1", seconds & " Second", _
        seconds & " Seconds"))

If seconds > 30 Then Minutes = Minutes + 1
If Minutes > 59 Then hours = hours + 1: Minutes = 0

ElapsedTimeString = IIf(str = "", "0", str)

End Function

10/26/2007 1:59:00 AM
access 16762 articles. 3 followers. Follow

1 Replies

Similar Articles

[PageSpeed] 45

On Thu, 25 Oct 2007 18:59:00 -0700, Greg <>

>Is it possible to add timer so this text box and time difference can be 
>updated every second?

Not to the textbox, but you can use the Form's Timer event. Set the form's
Timer property to 1000 (milliseconds, to fire the event once a second) and its
On Timer event to code which sets the value of the textbox to your function.

             John W. Vinson [MVP]
10/26/2007 6:18:42 AM

Similar Artilces:

Seperating text/Numbers
Fantastic , thanks, that has done the tric -- scottymellot ----------------------------------------------------------------------- scottymelloty's Profile: View this thread: ...

Adding Blank Rows after the last Detail of the Report
Hi All, I've used this code from Dwayne: Private Sub Report_Page() Dim intNumLines As Integer Dim intLineNumber As Integer Dim intTopMargin As Integer Dim ctl As Control Dim intLineHeight As Integer intNumLines = 12 intTopMargin = Me.Section(3).Height intLineHeight = Me.Section(0).Height For Each ctl In Me.Section(0).Controls For intLineNumber = 0 To intNumLines - 1 Me.Line (ctl.Left, intTopMargin + _ (intLineNumber * intLineHeight)) - _ Step(ctl.Width, intLineHeight), , B Next Next End Sub My report needs to print blank rows (at least...

Adding hyperlinks with parameters
Hey everybody I have a batch file which needs to be run from an excel sheet with a parameter, like this: c:\1.bat myParameter But when i try to run the Hyperlink, the Excel shows an error message saying it can't open the specified file (probably because the is a space between the file and the parameter) is there any known way to run the link from the excel? On Mar 2, 12:45=A0pm, Pasha <> wrote: > Hey everybody > I have a batch file which needs to be run from an excel sheet with a > parameter, like this: > c:\1.bat myParameter > But when i ...

outlook vcard, ad integration user properties
my boss is trying to get hix fax# in his vcard. he is using his address from the global address list I have modified his profile in active directory users and computers: I go into AD users and computers, double click on his user, go to the telephones tab, and enter his fax #. but when I did this his fax # is still not being pulled up in his outlook vcard. Does anyone know where outlook is trying to get this field from / how i can get this field into his vcard? thx ...

Text to Column #4
Hello, I have the following text in column A, which is one line: :! 10428712 ! NAME LASTNAME ! 20092004 ! 00458921 ! PMIAVW ! Is it possible with a VBA macro to create a column everytime there's "!" and to delete ":" Thanks for any help, You're going to have to find out what those characters are. I like Chip Pearson's addin: CellView to tell me those funny characters. Then you could use a macro to clean them up: Option Explicit Sub cleanEmUp() Dim myBadChars As Variant Dim iCtr As Lon...

how do i add a number to a range of cells? I need to add 11.27 to a number of different cells each with a different number in them Put 11.27 in an empty cell, format it the same way as the numbers you want to add to, copy it, then select the numbers you want to add to and do edit>paste special and select add. -- Regards, Peo Sjoblom "Helpme" <> wrote in message > how do i add a number to a range of cells? I need to add 11.27 to a > number > of different cells e...

When adding attachments... Outlook the following errors comes up: "Out of memory or system resources, please close some programs and try again" Quotas are fine. I have deinstalled/reinstalled Office, cleaned 'temp' areas, and many other tidbits. Any other ideas? Thanks. This might help as i had this problem with Outlook 98. Is the file you are trying to copy to attach nested in sub folders? if so try and copy the attachment to a root drive like c:\ Ignore previous email. wrong spellin if the attachment is nested in sub folders(this means you have to open different folders to get to ...

Count cells that Contain text
Is there a way in excel to count the number of cells in a colum tha contain a specific piece of text, e.g. "ACT" I know that I can use the countif or sumproduct functions to coun cells which *only* contain "ACT" but I need to count the number o cells in a column which countain ACT but may also contain other text a well. You can manually do it using autofilters but I need to count it using formula. Any help would be greatly appreciated. Ta And -- Message posted from =COUNTIF(Range,"*ACT*") -- Regards, Peo Sjoblom (No private...

Save as Msg box
I have the follwowing to save as a form: Sub SaveAs() ' ChDir "V:\Netshare\Item Master Creation\2005 Item Request Submission" Do fName = Application.GetSaveAsFilename Loop Until fName <> False ActiveWorkbook.SaveAs Filename:=fName, FileFormat:=xlNormal End Sub Problems: 1. It doesn't go to the directory that I have above: "V:\Netshare\Item Master Creation\2005 Item Request Submission" 2. I want to enter a message box that confirms that yes they want to save after they have entered the name in the save as box. In the Excel hlp I was just ...

Using Concatenate function to generate text in Text Box
I would like to have a text box on my chart, whose text is generated by concatenating the values from two different cells (B4 and B6) on a specific worksheet in my Excel file. I was able to use a reference to cell B4 to generate the text for my text box using the following formula: ='SSTyp-AllD'!$H$4 However, when I try to enter either of the following formulas for the text box text: =concatenate('SSTyp-AllD'!$H$4, 'SSTyp-AllD'!$H$6) ='SSTyp-AllD'!$H$4 & 'SSTyp-AllD'!$H$6 I get the error message "The text you entered is not a valid refe...

adding new records
I am totally new to CRM, so I hope this is really easy question: This concerns permissions.. I have a "sales" group, and with one of those people i need to be able to let them add new records on behalf of other "sales" people. Is there like a standard permission setting for it? (obviously every "sales" person can add new records if they select them selfs as the owner) thanks, Michal. Hi, By default the person who creates the record will be the owner. After record creation the person could reassign the record (manually) to another user. If all rec...

Picture Disappears When Added To Contact In Outlook 2003
Can someone help please. When I try to attach a picture to a contact in outlook 2003 immediately I double click the picture to be attached it disappears out of the outlook contact along with the placement holder in the form. Only when I right click the mouse and go remove picture do I get the placement holder back. I have looked at all the help menus but they offer no clues. Thanks TS ...

Size e-mail box
SSBmb3JnZXQuLiB3aGVyZSBpbiBFeGNoYW5nZSAyMDAwIEkgY2FuIGNoYW5nZSBkZWZhdWx0IHNl dHRpbmcgb2YgIGVtYWlsIGJveCBzaXplID8/Pw0KDQpTa2FsYQ== Skala wrote: > I forget.. where in Exchange 2000 I can change default setting of > email box size ??? If you're going to change it for a single AD user then this is done by taking Properties of the user in Active Directory Users and Computers MMC > Exchange General tab > Storage Limits. -- Henrik Walther Exchange MVP "Skala" <> wrote: >I forget.. where in Exchan...

Adding ActiveX to dialog with wrapper
When I add an ActiveX object to a dialog using the dialog editor - right click - insert activeX object, the help on the resulting activex selection tool states that a wrapper will not be added by using this method. If you need a wrapper, it suggests using the class view. This is using Visual Studio 2005. I'm having some problems with this on an existing project. To make sure I understand the process, I created a new MFC project, added a dialog, created a class for that dialog and added a Flexgrid object using the right click method in the dialog. I then added a variable for the flexgrid...

Make Outlook 2003 default to and use Large Text size in incoming HTML messages.
How can I make Make Outlook 2003 default to and use Large Text size in incoming HTML messages. -- "J. J." JDJ <jj@invalid.invalid> wrote: > How can I make Make Outlook 2003 default to and use Large Text size in > incoming HTML messages. I would think that the sender controls the text size for incoming HTML messages. -- Brian Tillman On the View Drop Down of an open message window there is a Text Size menu bar which when you mouse on it gives you 5 choices. I just want it to default to largest so I don't have to go through that with each new message I read. ...

Adding alternate columns
I work on a schedule where I record ticket count and ticket sales for each show, listed chronologically. Column A = week ending date Column B = # Tickets sold for April 5 show Column C = Ticket Revenue for April 5 show Column D = # Tickets sold for April 9 show Column E = Ticket Revenue for April 9 show Column F = # Tickets sold for April 12 show Column G = Ticket Revenue for April 12 show Column H = Total # Tickets sold for all shows Column I = Total Ticket Revenue for all shows In the Totals columns, the Total Tickets formula is "+B4+D4+F4", and the Total Revenue f...

Special Text...
How do I create the Registered symbol (R with a circle around it), within my text? Thanks, RAB_Missouri left Alt + 0174 � Otherwise, help us help you, state the meanings of "create" and "text". "RAB_Missouri" <> wrote in message > How do I create the Registered symbol (R with a circle around it), within my text? > > Thanks, > RAB_Missouri � Alt+0174 if you enter via kbd Look at Programs/Accessories/SystemTools/CharacterMap (if u have it installed) ...

Text area rendering
I have a word template email that I have created in Word 2000 that contains a text area (white box with scroll bar to enter text into). When I send this all service providers have no problems rendering it and allowing the user to add information to the box when they reply to the message. The only issue I'm having is with Outlook 2000, and it just started today. When I choose reply in the email with the text area and double click on the text area, it moves the cursor inside of the text box like it should. Now, in the past (5 days ago) and with online providers I can then type into the box. ...

As you know, the function =DATEVALUE("8/22/2008") produces a date from its corresponding text representation. I want to go the OTHER way. That is, I want to take a date and produce its text representation (I'll settle for any reasonable format). How might I go about doing that? Thanks, John Your answer is in your question!! try: =TEXT(TODAY(),"dd-mm-yy") or any other reasonable date-style format -- Gary's Student "JMF" wrote: > As you know, the function > > =DATEVALUE("8/22/2008") > > produces a date from its corr...

Adding fields from a different query
I have a form built based on a main query. How do I add more fields on that form that come from a different query? Anne A couple possibilities... Change your first query to include the extra fields. Use your second query to "feed" a form, then embed that form as a subform on your main form. Good luck! Regards Jeff Boyce Microsoft Access MVP -- Disclaimer: This author may have received products and services mentioned in this post. Mention and/or description of a product or service herein does not constitute endorsement thereof. Any code or pseudoco...

Adding more than three Conditions to 'Conditional Formatting'
Can i add more than three conditions to the conditional formatting presets using code? Regards [Riz] -- Rizitsu ------------------------------------------------------------------------ Rizitsu's Profile: View this thread: Riz, as you have found out, only 3 conditions with conditional formatting. But yes you can use some code to get more than 3, try this it will change the cell color in column A when you put in one ,two, three, or four, right click on the she...

Reposition comment boxes in 2000
With Excel 2000, is it possible to reposition comment boxes? I know I can drag them whilsediting, but that only affects where they appear during editing. Can I change the position they are displayed when I just hover over the cell? ...

Delimiter for adding Appointment in Entourage
Version: 2008 Operating System: Mac OS X 10.5 (Leopard) Processor: Power PC Email Client: Exchange What's the delimiter that Entourage uses if I want to add an appointment and the subject needs to be parsed by the Exchange server? <br><br>In Outlook, the hash/pound key (#) is used as delimiter. How about in Entourage 2008? <br><br>Basically, if I add an entry in a group calendar Out-Of-Office with the subject: #User1# On-Leave <br><br>in Outlook, this entry appears in the group calendar Out-Of-Office and also in User1's personal calendar. <...

Change default font for text boxes in Publisher
Is there any way to change the default font for text boxes in Microsoft Publisher fo all publications? Setting Text Defaults using by Brian Kvalheim -- Mary Sauer MSFT MVP news:// "JennyN" <> wrote in message > Is there any way to change the default font for text boxes in Microsoft...

Updating data in a dropdown box
I have a form with dropdown boxes. If the data is not in the list I have a button to go to the client table to add the new client and then return to the original form. When I click the dropdown box the client that was added is not in the list. If I advance to a new record and then back the name then shows up. How can I have the current list display? Thanks for any help you can give me. ...