Results 1 to 7 of 7
  1. #1
    joym is offline Advanced Beginner
    Windows 10 Access 2013 64bit
    Join Date
    Feb 2017
    Posts
    57

    Exclamation converting equation into code


    I have a text field named txtA that has the equation
    Code:
    =DateDiff("n",[Date_Fault_Lodged],[Resolution_Date_And_Time])
    i have another text field with this equation

    Code:
    =(1-([txtA]/525000))*100
    I would like to firstly change this to VBA code however i donot have the first clue of how to do this. also i would like to show the result in four decimal place and percentage

  2. #2
    andy49's Avatar
    andy49 is offline VIP
    Windows 10 Access 2007
    Join Date
    Nov 2016
    Location
    London
    Posts
    1,051
    Can we ask why? As you have something which clearly works


    Sent from my iPhone using Tapatalk

  3. #3
    joym is offline Advanced Beginner
    Windows 10 Access 2013 64bit
    Join Date
    Feb 2017
    Posts
    57
    Quote Originally Posted by andy49 View Post
    Can we ask why? As you have something which clearly works


    Sent from my iPhone using Tapatalk
    The second code does give the correct result but the does not store in the corresponding column in the table.i believe the reason is because when the text box is equal to
    Code:
    =(1-([txtA]/525000))*100
    so is the control source thus it does not save the value in the table. For all other text boxes with calculations it is in vba code and the control source is the corresponding column in the table thus all those equations gets stored.

    that is i would like to to convert that custom code into vba also however im not sure what to define and how.

  4. #4
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,518
    See Allen's thoughts:

    http://allenbrowne.com/casu-14.html

    as noted in the second section, you could put your calculation in the after update event of txtA.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  5. #5
    joym is offline Advanced Beginner
    Windows 10 Access 2013 64bit
    Join Date
    Feb 2017
    Posts
    57
    Quote Originally Posted by pbaldy View Post
    See Allen's thoughts:

    http://allenbrowne.com/casu-14.html

    as noted in the second section, you could put your calculation in the after update event of txtA.
    i tried

    Code:
    Me.availability =(1-([txtA]/525000))*100 
    i get a run time error

  6. #6
    joym is offline Advanced Beginner
    Windows 10 Access 2013 64bit
    Join Date
    Feb 2017
    Posts
    57
    I was able to to identify the run time error. The formular works fine however i still need to round off the result to 4 decimal places and show it in percentages

  7. #7
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,518
    Use the Round() function and format the textbox as desired.
    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. converting code to 64bit
    By markjkubicki in forum Programming
    Replies: 1
    Last Post: 03-09-2015, 09:16 AM
  2. converting access 32 bit code to 64 bit
    By markjkubicki in forum Programming
    Replies: 2
    Last Post: 04-01-2014, 08:14 PM
  3. Converting SQL to VBA code
    By Davidyam in forum Access
    Replies: 3
    Last Post: 04-18-2012, 10:29 AM
  4. Replies: 5
    Last Post: 01-05-2012, 11:55 AM
  5. Converting a Code to Text
    By rmcafee in forum Programming
    Replies: 7
    Last Post: 09-13-2011, 08:52 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