Automated / transparent conversion in text box control

ZikO

Registered User.
Local time
Today, 09:24
Joined
Dec 15, 2012
Messages
41
Hi everyone,

I am looking for an advice in this thread.

I have a text box control in a form that is bound to a table field. The field is of numeric format that stores time duration in minutes. I would like to apply sort of transparent / automated conversion. It would work so follows:
- when someone read records, the text box would convert a integer number stored in the filed into text so that the text box would show the time duration in this form "HH:MM"
- when someone clicks on the text box to change the value, one would input the value in this form again "HH:MM" but the text would be converted to minutes and then stored in the database.

I don't know if it's possible. I don't know which event(s) I would have to code to make it worked. If there are better solution to this, I am happy to see them.

Thanks
 
I would suggest using 2 text boxes, txt1 one would store the number of minutes (Integer data type) and the other txt2 would be a standard text field.
When the number of minutes is updated in txt1, you can update the value in txt2 using something like Me.txt2 = Format(Int(Me.txt1/60), "00") & ":" & Format(Me.txt1 Mod 60, "00")
This can be used in the AfterUpdate event of txt1 and also on the OnCurrent event of the form itself.
I don't see a way of achieving this using only one field.

David
 
I would suggest using 2 text boxes, txt1 one would store the number of minutes (Integer data type) and the other txt2 would be a standard text field.
When the number of minutes is updated in txt1, you can update the value in txt2 using something like Me.txt2 = Format(Int(Me.txt1/60), "00") & ":" & Format(Me.txt1 Mod 60, "00")
This can be used in the AfterUpdate event of txt1 and also on the OnCurrent event of the form itself.
I don't see a way of achieving this using only one field.

David

Hi David

Thanks for this clue. It helped :)
 

Users who are viewing this thread

Back
Top Bottom