Results 1 to 8 of 8
  1. #1
    Super Moderator
    Join Date
    Jun 2002
    Location
    Mt Macedon, Victoria, Australia
    Posts
    3,993
    Thanks
    1
    Thanked 45 Times in 44 Posts
    On a continuous form, a field requires a numeric entry. I have been asked whether they can type in Fractions and have them converted to decimals "like Excel" does.

    So I have written a function to parse the text, and if it looks like a fraction, pull it apart and calculate a decimal.

    Question is: where do I run the code? I need to convert it before Access gets a chance to complain about having text in a numeric field.
    At the moment I use the Key Down event, checking for the Tab key or Enter key to indicate data entry is finished. This works, but depends on the user using either of those keys to exit the field. If they exit with the mouse, then Access complains about the data type.

    Is there any other event that would execute before the text entered is committed? Nothing I have tried works.
    Regards
    John



  2. #2
    Platinum Lounger
    Join Date
    Dec 2001
    Location
    Melbourne, Australia
    Posts
    4,594
    Thanks
    0
    Thanked 27 Times in 27 Posts
    [quote name='johnhutchison' post='793976' date='19-Sep-2009 13:50']On a continuous form, a field requires a numeric entry. I have been asked whether they can type in Fractions and have them converted to decimals "like Excel" does.

    So I have written a function to parse the text, and if it looks like a fraction, pull it apart and calculate a decimal.

    Question is: where do I run the code? I need to convert it before Access gets a chance to complain about having text in a numeric field.
    At the moment I use the Key Down event, checking for the Tab key or Enter key to indicate data entry is finished. This works, but depends on the user using either of those keys to exit the field. If they exit with the mouse, then Access complains about the data type.

    Is there any other event that would execute before the text entered is committed? Nothing I have tried works.[/quote]
    Is the fraction field bound?

    Why not try an unbound field, can you then use the BeforUpdate event of this control.

  3. #3
    Super Moderator
    Join Date
    Jun 2002
    Location
    Mt Macedon, Victoria, Australia
    Posts
    3,993
    Thanks
    1
    Thanked 45 Times in 44 Posts
    [quote name='patt' post='793991' date='19-Sep-2009 18:25']Is the fraction field bound?

    Why not try an unbound field, can you then use the BeforUpdate event of this control.[/quote]
    Thanks Pat

    Yes it is bound. It is a continuous form. On a continuous form an unbound control shows the same value for each record, as the 12s in the shot below .

    [attachment=85600:unbound.gif]
    Attached Images Attached Images
    Regards
    John



  4. #4
    Platinum Lounger
    Join Date
    Dec 2001
    Location
    Melbourne, Australia
    Posts
    4,594
    Thanks
    0
    Thanked 27 Times in 27 Posts
    [quote name='johnhutchison' post='793992' date='19-Sep-2009 19:43']Thanks Pat

    Yes it is bound. It is a continuous form. On a continuous form an unbound control shows the same value for each record, as the 12s in the shot below .

    [attachment=85600:unbound.gif][/quote]
    Sorry I didn't notice that it was a continuous form.
    Maybe have 2 bound fields here.

  5. #5
    Super Moderator
    Join Date
    Jun 2002
    Location
    Mt Macedon, Victoria, Australia
    Posts
    3,993
    Thanks
    1
    Thanked 45 Times in 44 Posts
    I agree that you could have a text field, where data entry takes place, and a numeric field calculated from the text field, in the after update event.
    My worry is that users might find it confusing. I already have a lot of fields squeezed onto a form, and I would prefer to avoid adding another.
    Regards
    John



  6. #6
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts
    Trying to enter fractions in a text box bound to a number field in a continuous form is bound (hah!) to cause problems. If you really do need it, you'd have to use multiple text boxes to avoid the problems - either separate text boxes for the whole number, numerator, denominator and the resulting number, or a text box for data entry and another for the resulting number. But you have indicated that that is not an attractive option in your situation, so I think it'd be best not to allow fractions at all.

  7. #7
    Super Moderator
    Join Date
    Jun 2002
    Location
    Mt Macedon, Victoria, Australia
    Posts
    3,993
    Thanks
    1
    Thanked 45 Times in 44 Posts
    Thanks
    You are probably right!
    But I think I will let them try it for a while and see how often it works, and how often it causes problems.
    There are only 2 people who enter this data, and I think they would be prepared to try it, on the understanding that I don't 'guarantee' anything at the moment.
    If they resort to using a calculator, nothing much has been lost.
    Regards
    John



  8. #8
    Plutonium Lounger
    Join Date
    Mar 2002
    Posts
    84,353
    Thanks
    0
    Thanked 29 Times in 29 Posts
    You could provide a popup calculator in your database - see Post 697786.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •