473,503 Members | 1,646 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.microsoft.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 2115
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
5560
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...
8
2447
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...
2
3859
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...
0
1328
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...
4
2686
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...
2
11234
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...
6
3708
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
5140
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...
1
2227
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...
4
3919
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...
0
7198
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,...
0
7072
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7271
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,...
0
7449
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
4998
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...
0
4666
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...
0
3160
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3149
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1498
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

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.