Capturing minutes and seconds only?

Hi all,

How would I do this?  I have a time field which I have set the format to nn:ss but entering 05:45 becomes 05:45:00 - How do I get around this?  

Regards

Chris
smodsAsked:
Who is Participating?
 
Gustav BrockConnect With a Mentor CIOCommented:
Here is how:

1. Apply an inputmask of:

"00:"00:00

2. Use this code:
Private Sub txtTime_Click()

  If Me!txtTime.SelStart < 3 Then
    Me!txtTime.SelStart = 3
  End If
  Me!txtTime.SelLength = 1
  
End Sub

Private Sub txtTime_Enter()

  Me!txtTime.SelStart = 3
  Me!txtTime.SelLength = 1
  
End Sub

Open in new window


/gustav
0
 
Simon BallCommented:
enter it as 00:05:45?
0
 
Simon BallCommented:
you might need to give more detail?  could you convert your time to just seconds and store it as an integer?
0
Free Tool: Site Down Detector

Helpful to verify reports of your own downtime, or to double check a downed website you are trying to access.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

 
MINDSUPERBCommented:
Chris,

Try this format:

=Format(Now(),"m:s")

Sincerely,
Ed
0
 
smodsAuthor Commented:
Hi guys,

Sorry I wasn't clear! It's for capturing an average transaction time.  If possible I wouldn't want to enter it as 00:05:45

Regards

Chris
0
 
peter57rCommented:
There isn't any way of entereing just minutes and seconds into a time field.  As you have found , Access will always treat such an entry as hours and minutes.

You can use the technique suggested by Sudonim or you can use two fields, one for minutes and one for seconds and then build the time value in code.

Or you can use the afterupdate event of the entry and rebuild the time using..

me.textboxname= timeserial(0, Hour(me.textboxname), minute(me.textboxname))
0
 
smodsAuthor Commented:
could you convert your time to just seconds and store it as an integer?

So would I enter the time but in seconds? The two text box solutions doesn't sound ideal.  How would I do this?
0
 
MINDSUPERBCommented:
I am sorry Chris for my first post.

Yeap, I agree with Peter. Date/Time field allows only entry for a day and a time.

If you want to view elapsed time and showing it in minute:seconds then you change the date/time field into a number and enter the elapsed time in seconds. Then, calculate the value into minute:second for display purposes.

Ed

0
 
smodsAuthor Commented:
Thanks Ed.  How would I do that?

Regards

Chris
0
 
MINDSUPERBCommented:
Chris,

Here it is:

Private Sub t1_AfterUpdate()
Me.MinSec = Me.t1 / 86400
End Sub

t1 = Field name of where you enter the elapsed values in seconds
MinSec = Unbound field that display the minutes:seconds

You need to format the MinSec field with "m:s".

Sincerely,
Ed
0
 
MINDSUPERBCommented:
Replace  Me.MinSec = Me.t1 / 86400 witht the code below instead:


Me.MinSec = Int(Me.t / 60) & ":" & (Me.t - (60 * Int(Me.t / 60)))

Ed
0
 
MINDSUPERBCommented:
Chris,

Pratima's post at ID:34941778 provided the codes I posted above. You can refer that link for more info.

Ed
0
 
als315Commented:
Why not to use something like this?
DB26835639.accdb
0
 
smodsAuthor Commented:
Works like a charm!

Many thanks!!

Chris
0
 
Gustav BrockCIOCommented:
You are welcome!

/gustav
0
 
Simon BallCommented:
nice work all.
that will teach me to take a long lunch break :)
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.