473,651 Members | 3,029 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to transfer numbers in an unbound text box to a number field in a table?

I have stopwatch function on my form that works fine. I used code from http://support.microso ft.com/kb/233275.
My problem now is taking the value from the unbound text box and entering into my table for record time.

If I leave the field in the table as text will transfer fine but then I can not use the value in mathematical functions, which I need.

Can someone help me please?
Nov 3 '10 #1
2 2121
gnawoncents
214 New Member
My suggestion would be to store the numeric value as milliseconds in your table. That way you could perform any mathematical functions required. If you need both the text and numeric, then simply store both. You can pull the ElapsedMilliSec value from the events by adding a few lines to two of your events as seen below. Note: I added a textbox (txtTime) to my form in this case.

Expand|Select|Wrap|Line Numbers
  1. Private Sub btnReset_Click()
  2.  
  3.    TotalElapsedMilliSec = 0
  4.    Me!ElapsedTime = "00:00:00:00"
  5.    'Add this line to reset the numeric value ( in milliseconds)
  6.    Me!txtTime = 0
  7.  
  8. End Sub
  9.  
  10. Private Sub Form_Timer()
  11.  
  12.    Dim Hours As String
  13.    Dim Minutes As String
  14.    Dim Seconds As String
  15.    Dim MilliSec As String
  16.    Dim Msg As String
  17.    Dim ElapsedMilliSec As Long
  18.  
  19.    ElapsedMilliSec = (GetTickCount() - StartTickCount) + _
  20.       TotalElapsedMilliSec
  21.  
  22. 'Add this line to get the numeric value ( in milliseconds)
  23. Me.txtTime = ElapsedMilliSec
  24.  
  25.    Hours = Format((ElapsedMilliSec \ 3600000), "00")
  26.    Minutes = Format((ElapsedMilliSec \ 60000) Mod 60, "00")
  27.    Seconds = Format((ElapsedMilliSec \ 1000) Mod 60, "00")
  28.    MilliSec = Format((ElapsedMilliSec Mod 1000) \ 10, "00")
  29.  
  30.    Me!ElapsedTime = Hours & ":" & Minutes & ":" & Seconds & ":" _
  31.       & MilliSec
  32.  
  33. End Sub 
Nov 3 '10 #2
Thank you very much. It worked great. I was just over thinking it.
For anyone else who needs this, I had to convert the milliseconds to seconds and use the DateAdd function to my time stamp to get a stop date and time.
Nov 5 '10 #3

Sign in to post your reply or Sign up for a free account.

Similar topics

2
5577
by: Jayjay | last post by:
I've got a report that has a series of unbound text boxes that are being populated by some variables in code. The format is supposed to be a currancy format, but on a certain series of boxes, I need add " ** " or something to denote those particular boxes so they can get the reader to see the footnote for those figures. The report is currently setup to put the text in those boxes in red. This is all well and good on the screen - but...
8
2455
by: shumaker | last post by:
I see other posts where some say fields that will hold a number with leading zeros should be stored as text instead of numbers. This is very inefficient though, as a string of digit characters takes up much more memory than a 32bit or even a 64bit int. Storing as a number still allows for formatting when displaying the number, correct? I am creating a table and would like opinions regarding this please.
2
3879
by: Zlatko Matiæ | last post by:
Hello. I have the following problem with MS Access/PostgreSQL combination: There is a form in Access that has an unbound text box, used for entering a commentary of a batch of records. There is a DAO Append Query that has a parameter that is passed from the text box using parameter of DAO QueryDef object. I adjusted B7 parameter (Text as LongVarchar) in connection string (ODBC driver) to 1, so that Access links PostgreSQL Text fields as...
0
1334
by: icezcube | last post by:
I am not a programmer and a newbie with MS Access. I hope you guys can help me with my problem. I'm creating an IT hardware inventory database for my company. We have a few branches and each branches will have their own branch code. For example :- PKGL07 PKGL14 KLIA HQ and so on....
4
2698
by: gitimaya | last post by:
hi can someone help me. I have two talbed. In one table (A)a field is having numbers like 111,222,333(field name (data"). In another table I have a field which has abc111222333xxx(B)(field name data1. I got to extract all those records from table A whose values are not included in any row data of table B. I tried: select count(*) from table B where data1 like (select data from table A); Thhe problem here is the number in the string of...
2
11250
by: Nhoung Ar | last post by:
Can anybody out there help me please on apply filter in MS Access. I have a form that create from the query, which contain field chidid (text field), in the form footer, I add the button to open another form (searchF form), which have an unbound text box (text1). It works fine with this code: DoCmd.ApplyFilter , "childid='" & Form_SearchF.Text1 & "'" But if I change the data type of childid field to number it does't work. The error...
6
3724
kcdoell
by: kcdoell | last post by:
Hello: I three fields on a continuous form: , & On the same form I have an unbound text box with the following formula in the control source: =Sum(IIf(=50,,0)) This worked great.
11
5155
by: jwessner | last post by:
I have a form (Form1) which contains basic Project data and a subform listing the personnel assigned to the Project as a continuous form. Selecting a person on that project and clicking on a command button will open a new form (Form2). Form2 has two subforms. Both are embedded in the main form. (Subform2 is NOT embedded in subform1.) Subform1 displays records as a continuous form based on the Primary ID of the main form and lists the...
1
2235
by: MyWaterloo | last post by:
I have an unbound text box on my main form that is used to show the sum totals in my sub form. I also have a field on my main form that has a control source in a table. This bound field needs to somehow have the total form the unbound text box transferred to it. How do I go about this? I have multiple categories that can be selected through a combo box. So I am sometime just flipping through categories to see what my total is. I could just...
4
3940
by: bkberg05 | last post by:
Hi I have a form called Customer whose record source is a table called Customer. The primary key is Customer_ID. On that form, there's a subform called sub_Customer_Contact_Log. It's record source is a table called Customer_Contact_Log. It's primary key is Customer_Contact_Log_ID. The subform is linked to the main form by Customer_ID (which is in both the Customer table and the Customer_Contact_Log tables). I've put an unbound...
0
8357
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8803
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8700
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8465
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7298
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6158
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5612
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
1
1910
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1588
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.