Results 1 to 10 of 10
  1. #1
    data808 is offline Noob
    Windows XP Access 2010 32bit
    Join Date
    Aug 2012
    Posts
    727

    Input mask or expression

    Not sure which one I need but I have a text box that I am manually typing in "1hr 30mins" as an example. I need something to auto format this for me. Ultimately what I want is to type "90" and it will turn it into "1hr 30mins" for me. If thats too hard, I will settle for me typing "130" and it just fills in the "hr" and "mins" for me. This would help me enter records a lot faster. Thank you.

  2. #2
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,902
    Just save the value as 90 in a number field and calculate it to hrs/mins in query or textbox. Leaving the value as minutes in table will allow greater versatility (sum, average, minimum, maximum, etc).
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  3. #3
    Missinglinq's Avatar
    Missinglinq is offline VIP
    Windows 7 64bit Access 2007
    Join Date
    May 2012
    Location
    Richmond (Virginia, not North Yorkshire!)
    Posts
    3,018
    Quote Originally Posted by June7 View Post

    ...Just save the value as 90 in a number field and calculate it to hrs/mins in query or textbox. Leaving the value as minutes in table will allow greater versatility (sum, average, minimum, maximum, etc)...
    I agree with June7 on this. Where TotalMinutes is the original Field or Textbox and FormattedTime is the Calculated Field, the general expression would be

    As the Control Source of an Unbound Textbox

    = ([TotalMinutes] \ 60) & "hrs" & " " & ([TotalMinutes] Mod 60) & "mins"

    As a Calculated Field in a Query

    FormattedTime: ([TotalMinutes] \ 60) & "hrs" & " " & ([TotalMinutes] Mod 60) & "mins"

    Linq ;0)>
    The problem with making anything foolproof...is that fools are so darn ingenious!

    All posts/responses based on Access 2003/2007

  4. #4
    data808 is offline Noob
    Windows XP Access 2010 32bit
    Join Date
    Aug 2012
    Posts
    727
    Ok this would work. So theres no way I can type in the same field as the calculated field? Like type 105 and in the same cell it converts the text to 1hr 45mins?

  5. #5
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,902
    You can. It would require textbox BeforeUpdate or AfterUpdate event VBA code to calculate the conversion and save it into the field. I am suggesting the minutes value in the table is more useful. If you want can have another textbox on the form with calculation to display the hrs/mins calc, just don't bother with code to save.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

  6. #6
    data808 is offline Noob
    Windows XP Access 2010 32bit
    Join Date
    Aug 2012
    Posts
    727
    I renamed the textbox that I would type in the amount of minutes to "TotalMinutes" and renamed the other calculated textbox to "FormattedTime" but the expressions did not work. I put the expressions into the control source property for both textboxes. Now the textbox that I'm supposed to type the amount of minutes into is locked with #Error displaying. The calculated field is displaying #Name?. Am I doing something wrong?

  7. #7
    data808 is offline Noob
    Windows XP Access 2010 32bit
    Join Date
    Aug 2012
    Posts
    727
    Never mind I got it to work. Thanks very much for all your help. Thanks also for posting the expression. I have no idea how to write those things.

  8. #8
    data808 is offline Noob
    Windows XP Access 2010 32bit
    Join Date
    Aug 2012
    Posts
    727
    I am trying to recreate this and now I can't remember what I did to get this to work. I am basically doing what I mentioned before. I am pasting these expressions into the control source property and its not working. The fields boxes are locked with either Name? or #Error. I can't type anything in to it. Please help! This is driving me crazy because I did get it to work before I just forgot I what did.

  9. #9
    data808 is offline Noob
    Windows XP Access 2010 32bit
    Join Date
    Aug 2012
    Posts
    727
    Ok I finally got it to work again and this time I am saving it so I can refer back to it. I guess I will post what I did. The "TotalMinutes" = the name of the field box that I will be entering the minutes of the movie. (90 for example) All I needed was that first expression = ([TotalMinutes] \ 60) & "hrs" & " " & ([TotalMinutes] Mod 60) & "mins" to be typed into the new unbound field box that in design view. In my case the field box that I would be typing the 90 into is bound to "Length:" on my table and is also called "Length:". So I needed to change all the "TotalMinutes" in the expression to "Length:" then it it worked!

    I should mention that I did find another flaw though. So now that expression is working but not always. If I type in 90 and press tab, it will calculate into my unbound text box with the expression you provided in it. However, if I type in 90 and press enter, the cursor drops down and the 90 disappears because the field box is only 1 line in height size. So it looks like the 90 is gone but its actually above the cursor. How do I prevent this from dropping down the cursor if I hit enter? I would like to be able to press enter or tab to go to the next control box.

  10. #10
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,902
    Check the textbox Enter Key Behavior property on the Other tab of Property Sheet. If it says New Line in Field, change it to Default.
    How to attach file: http://www.accessforums.net/showthread.php?t=70301 To provide db: copy, remove confidential data, run compact & repair, zip w/Windows Compression.

Please reply to this thread with any new information or opinions.

Similar Threads

  1. input mask
    By slimjen in forum Forms
    Replies: 7
    Last Post: 10-07-2013, 03:20 PM
  2. Input Mask Question
    By MM12 in forum Access
    Replies: 2
    Last Post: 09-10-2012, 11:03 AM
  3. No Input Mask for a Web Database
    By Modify_inc in forum Access
    Replies: 1
    Last Post: 08-18-2012, 10:29 PM
  4. Input Mask
    By qbc in forum Access
    Replies: 2
    Last Post: 01-20-2012, 03:27 PM
  5. Input mask
    By doobybug in forum Access
    Replies: 2
    Last Post: 06-17-2009, 09:40 PM

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Other Forums: Microsoft Office Forums