Results 1 to 11 of 11
  1. #1
    dniezby is offline Competent Performer
    Windows 8 Access 2013
    Join Date
    Apr 2013
    Posts
    183

    Anyone able to translate a formula from excel?

    I have to figure out how to get working in my application.

    Here is the original forumula

    round(if(r - (n * 0.3) < 0.51, 20 * (sqrt(sqrt(n) * n / r)) + 20, 20))

    the value for "R" will be taken from this same record from a field called, "finish_position"
    the "N" needs to come from a different table called, "events" field name "attendance"

    I'm thinking that I first need to do a DLookup to assign the attendance to a variable.

    Code:
    varAtt = DLookup ("attendance","events", "event_id=" & event_id)
    I tried to just replace the N and R with the field names but it was giving me an error.

    Compile Error:
    Expected: Expression
    As I'm writing this, I think I might be able to break it up and put it into an "if then"

  2. #2
    rzw0wr is offline I will always be a newbie
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2013
    Location
    Indiana
    Posts
    479
    Square root in Access is Sqr()

    The rest should work.

    Dale

  3. #3
    dniezby is offline Competent Performer
    Windows 8 Access 2013
    Join Date
    Apr 2013
    Posts
    183
    Quote Originally Posted by rzw0wr View Post
    Square root in Access is Sqr()

    The rest should work.

    Dale
    Thanks Dale, I'll give it a shot.

  4. #4
    dniezby is offline Competent Performer
    Windows 8 Access 2013
    Join Date
    Apr 2013
    Posts
    183
    Quote Originally Posted by rzw0wr View Post
    Square root in Access is Sqr()

    The rest should work.

    Dale
    I still get the same error..then it highlights the IF in my statement as noted by the colored section.

    here is where I'm at right now.

    Code:
    Private Sub finish_position_Change()
    varAtt = DLookup("attendance", "events", "event_id=" & event_id)
    
    finish_points = round(if(finish_position - (varAtt * 0.3) < 0.51, 20 * (sqr(sqr(varAtt) * varAtt / finish_position)) + 20, 20))
    end sub

  5. #5
    ssanfu is offline Master of Nothing
    Windows XP Access 2000
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    You need to use immediate if function >> IIF(condition, Value if TRUE, Value if FALSE )

  6. #6
    rzw0wr is offline I will always be a newbie
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2013
    Location
    Indiana
    Posts
    479
    Thanks ssanfu.
    I missed that.

    Dale

  7. #7
    dniezby is offline Competent Performer
    Windows 8 Access 2013
    Join Date
    Apr 2013
    Posts
    183
    Quote Originally Posted by ssanfu View Post
    You need to use immediate if function >> IIF(condition, Value if TRUE, Value if FALSE )
    I have no idea what that means. So how do I translate that my formula???

  8. #8
    rzw0wr is offline I will always be a newbie
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2013
    Location
    Indiana
    Posts
    479
    round(if(r - (n * 0.3) < 0.51, 20 * (sqrt(sqrt(n) * n / r)) + 20, 20))
    Round(Iff(-(N*0.3) < 0.51, 20* (sqr(sqr(n)*n/r))+20,20))

    Basically just change the If to Iff.

    Untested. Just put into an Iff() statement.

    Dale

  9. #9
    dniezby is offline Competent Performer
    Windows 8 Access 2013
    Join Date
    Apr 2013
    Posts
    183
    Quote Originally Posted by rzw0wr View Post
    Round(Iff(-(N*0.3) < 0.51, 20* (sqr(sqr(n)*n/r))+20,20))

    Basically just change the If to Iff.

    Untested. Just put into an Iff() statement.

    Dale
    Giving it a test now. Thanks everyone.

  10. #10
    ssanfu is offline Master of Nothing
    Windows XP Access 2000
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    Code:
    Round(Iff(-(N*0.3) < 0.51, 20* (sqr(sqr(n)*n/r))+20,20))
    That should be IIf()



    IIF(condition, Value if TRUE, Value if FALSE )
    This is the general syntax if the immediate if function ...

  11. #11
    dniezby is offline Competent Performer
    Windows 8 Access 2013
    Join Date
    Apr 2013
    Posts
    183
    Okay, that seems to work. Now I just need to put it in the correct event trigger.

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

Similar Threads

  1. Replies: 1
    Last Post: 09-30-2012, 07:03 AM
  2. Excel Formula into Access Query
    By dr4ke in forum Queries
    Replies: 7
    Last Post: 06-25-2012, 06:46 AM
  3. Excel Formula Needed in Access
    By bmschaeffer in forum Queries
    Replies: 4
    Last Post: 01-18-2012, 01:13 PM
  4. Replies: 5
    Last Post: 12-14-2011, 08:24 AM
  5. Replies: 0
    Last Post: 09-03-2009, 01:58 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