Minutes and Seconds Field

Copper Contributor

Hi everyone, somewhat new to the world of access, and I have run into a seemingly simple problem, that I cannot find an answer to online. How can I create a field, with the format minutes and seconds. If I try to put in the custom format nn:ss, it will still ask for hh:nn:ss. How can I solve this problem?

8 Replies

@Jqws13_ 

That is correct. Even worse, on a new record, 00:00 will be displayed, but - even worse - if you enter, say, 48:37, Access will report "Invalid date", as the entry will be parsed as hh:nn.

 

Your best option is probably to use two juxtaposed textboxes holding minutes and seconds respectively, and assemble these with TimeValue(0, n, s) to build the time in the BeforeUpdate event of the form, and use Minute([TimeField]) and Second([TimeField]) to display the time using the OnCurrent event of the form.

 

Ultimately, create a form using Inputmask and custom code similar to what I did here:

 

Entering 24-hour time with input mask and full validation in Microsoft Access 

If you enter e.g 0:48:37, it will be correctly displayed as 48:37
But Colin, entering hours is exactly what the questioneer wants to avoid.
Hi Gust
You may well be right but the OP didn't actually say that.
I was just trying to point out that the data entered doesn't have to be displayed in the same format.
I am not particularly wanting to avoid entering hours if that's what it means to make this easy. The only problem is, I am so new to access that I do not understand how access syntax works, nor do I know how to enter such code. When I do try to enter something like 0:23:47, without an input mask, and with the long time format, access changes it to say 12:23:47 AM. Not what I want. With the input mask "00":99:99, access rejects 00:23:47, saying it is not a proper time/date. My full problem is this: I have the lengths of some songs, that I want to record in my database. I don't know how I can represent just minutes and seconds in my database. I also do not understand nor know how to use access syntax or code.
I am not particularly wanting to avoid entering hours if that's what it means to make this easy. The only problem is, I am so new to access that I do not understand how access syntax works, nor do I know how to enter such code. When I do try to enter something like 0:23:47, without an input mask, and with the long time format, access changes it to say 12:23:47 AM. Not what I want. With the input mask "00":99:99, access rejects 00:23:47, saying it is not a proper time/date. My full problem is this: I have the lengths of some songs, that I want to record in my database. I don't know how I can represent just minutes and seconds in my database. I also do not understand nor know how to use access syntax or code. Thanks for your help so far though!

@Jqws13_ 


@Jqws13_ wrote:
I am not particularly wanting to avoid entering hours if that's what it means to make this easy. 

Then that is your solution.

You only miss to change the Format property of the textbox where you display the value to:

nn:ss

Remove an InputMask. It often causes more trouble than help.

Hi Gustav,
Here is my solution, and so far it has seemed to work. My custom format is nn:ss, and my input mask is "00":99:00;0;0* The hours are set to 0, which is what I wanted, and I can enter whatever amount of minutes and seconds as I like, and it will only appear with minutes and seconds.