Results 1 to 9 of 9
  1. #1
    Esmatullaharifi is offline Advanced Beginner
    Windows 8 Access 2013
    Join Date
    Nov 2014
    Posts
    40

    Copying Decimal value using vba

    Hello Dears!
    I have a form containing two text boxes (1Average, Average1) that the first one is containing formula typed in form and the result of that is in decimal data type. I want to copy the result in [1Average] to the [Average1] text box for this i used the following VBA code:
    Code:
    Private Sub Text151_AfterUpdate()
    [Average1] = Me.[1Average]
    End Sub
    but this code copy the value with full rounding the decimal part and doesn't copy the real decimal number for this i need your help to edit this code to copy the decimal value without any change and rounding.
    Thanks

  2. #2
    JoeM is offline VIP
    Windows XP Access 2007
    Join Date
    Jun 2012
    Posts
    3,904
    How have you formatted the Text Boxes on the Form?

  3. #3
    Esmatullaharifi is offline Advanced Beginner
    Windows 8 Access 2013
    Join Date
    Nov 2014
    Posts
    40
    Yes I have formated the [1Average] to Fixed format and nothing to the second text box

  4. #4
    JoeM is offline VIP
    Windows XP Access 2007
    Join Date
    Jun 2012
    Posts
    3,904
    What happens if you Format the second text box to Fixed also?

  5. #5
    Esmatullaharifi is offline Advanced Beginner
    Windows 8 Access 2013
    Join Date
    Nov 2014
    Posts
    40
    When i select the fixed for the second one the copied value is not changing (without decimal) it means before the formatting and after the formatting are the same (without decimal).

  6. #6
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,816
    Why do you have two textboxes for the same value?

    Is Average1 bound to a field or is that actually the field name? What is the field number type?
    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.

  7. #7
    Esmatullaharifi is offline Advanced Beginner
    Windows 8 Access 2013
    Join Date
    Nov 2014
    Posts
    40
    The first one is a field in form that i typed formula and the second one is linked to a table that I want copy the first field data to second one to store it in table.

  8. #8
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,816
    Saving calculated data is usually a bad idea, especially aggregate data. What are you calculating an average of?

    What is field size of the field you want to save the value into - Single, Double, Decimal? I always use Double for number data type.
    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.

  9. #9
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,518
    I doubt it's the formula, I think it's either the format of the target text box or the data type of the field it's bound to.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

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

Similar Threads

  1. Convert decimal comma to decimal point
    By Hans Karlsson in forum Programming
    Replies: 3
    Last Post: 06-30-2014, 01:56 PM
  2. Add decimal in position
    By BrianF in forum Import/Export Data
    Replies: 4
    Last Post: 04-15-2013, 12:18 PM
  3. Decimal Places
    By momodoujimnjie in forum Access
    Replies: 1
    Last Post: 01-09-2013, 04:49 AM
  4. Need Currency or Decimal Help!
    By Jaricketts in forum Access
    Replies: 2
    Last Post: 08-19-2010, 09:39 PM
  5. Converting HH:MM to decimal
    By katrinanyc926 in forum Queries
    Replies: 5
    Last Post: 08-13-2010, 02:39 PM

Tags for this Thread

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