Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Microsoft Office > Access and Access VBA > Access
Password Reminder
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
Access Discussion of Microsoft Access database design and programming. See also the forums for Access ASP and Access VBA.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Access section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old February 15th, 2005, 04:28 PM
Authorized User
Join Date: Dec 2003
Location: Brussels, , Belgium.
Posts: 20
Thanks: 0
Thanked 0 Times in 0 Posts
Default Stock Time in field

Hello all,
Here is a little question.
I'd like to store a time in a field like this "2mn. 13sec." but I like the user just to type "2:13". Got an idea?
I'd like it to be also entered in milliseconds "2:13:154".

I tried to solve this with input masks, but without any sufficient answers.

Thank you
Reply With Quote
  #2 (permalink)  
Old February 15th, 2005, 11:24 PM
Friend of Wrox
Join Date: Jun 2003
Location: , , USA.
Posts: 1,093
Thanks: 1
Thanked 12 Times in 11 Posts

Actually what you're attempting to store here, and what your users are entering, are simple string values, not time values as time values are understood by Access (8-byte floating point numbers).

You would need to write a little string parsing routine to locate the semi-colon in your string (e.g., Instr (1, "2:13", ":")), then parse off the characters strings to the right and left of the semi-colon, and append "mn." and "sec." respectively to the two sub-strings.

If I get some time I'll give it a whirl.


Reply With Quote
  #3 (permalink)  
Old February 15th, 2005, 11:39 PM
Friend of Wrox
Join Date: Jun 2003
Location: , , USA.
Posts: 1,093
Thanks: 1
Thanked 12 Times in 11 Posts

Also, if "2mn. 13sec." represents some sort of elasped time value, a better design might be to store an actual staring time value and ending time value in two Date/Time datatype fields (which would give you actual time values to work with), then calculate the elapsed time value in a query and format the time values there (though the custom format would still require treating the time value as a string in code somewhere so you could append the custom "mn." and "sec."
 suffix strings).


Reply With Quote
  #4 (permalink)  
Old February 16th, 2005, 09:04 AM
Friend of Wrox
Points: 9,611, Level: 42
Points: 9,611, Level: 42 Points: 9,611, Level: 42 Points: 9,611, Level: 42
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
Join Date: Mar 2004
Location: Washington, DC, USA.
Posts: 3,069
Thanks: 0
Thanked 10 Times in 10 Posts

Try parsing this with Split() instead of colon, like this:

If IsNull(Me.tbxYourTextBox) Then
   stTime = "00:00:000"
   Else: stTime = Me.tbxYourTextBox
End If

TimeArray = Split(stTime, ":")
   stMin = TimeArray(0)
   stSec = TimeArray(1)
   stMls = TimeArray(2)
stStoredValue = stMin & "mn. " & stSec & "sec. " & stMls & "mls."

   You may need to add error handling for missed milliseconds, etc.


Reply With Quote

Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off

Similar Threads
Thread Thread Starter Forum Replies Last Post
stock management- closing stock and opening stock bright_mulenga Access 1 July 16th, 2007 07:11 AM
Null Value for Date/Time Field ksegars4 Crystal Reports 2 November 17th, 2004 11:58 AM
Formatting a Field Containing a Time to AM/PM taleriana XSLT 2 March 16th, 2004 11:10 PM
Format Date to time field KennethMungwira VB.NET 3 November 17th, 2003 11:48 AM

All times are GMT -4. The time now is 06:05 PM.

Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.