Results 1 to 6 of 6
  1. #1
    krag is offline Medium experience
    Windows 10 Office 365
    Join Date
    May 2014
    Posts
    71

    Programming x^-y gives runtime error 5 - invalid procedure call or argument

    It seems that Access VBA does not accept negative value for power index in programming with ^ code.



    Me.ReqdSpPowerP = Round(Me.SpeedP * Me.FeedRateP * Me.ToolDiaP * Forms![PropoSetUpHeadF]![SetUpPF].Form![Ks] * (((Me.FeedRateP / Me.FluteNo) * Sin(Me.PtAngle * PI / 180)) ^ (-1 * Forms![PropoSetUpHeadF]![SetUpPF].Form![mc])) * (1 - Me.RakeAngle / 100) / Forms![PropoSetUpHeadF]![FixedFactorPF].Form![McEfficiency] / 240000, 2)

    If I removed (-1*) there is no error (of course it is not my desired result).
    Any suggestions to overcome this issue will be highly appreciated.

  2. #2
    CJ_London is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,397
    the principle of using a negative is fine - in the immediate window
    ?2^3
    8
    ?2^-3
    0.125

    Suggest review each calculated value and build a manual calculation in the immediate window

    Since you are referring to other forms, presumably those forms are open

    Maybe I'm missing something but there appear to be 7 ( and only 6 ) - but then I would expect you to get a vba syntax error

  3. #3
    krag is offline Medium experience
    Windows 10 Office 365
    Join Date
    May 2014
    Posts
    71
    For some reason the program as I mentioned above started working fine without error.
    I am not sure why it threw up error initially.
    If I get the error again, I will revert here.
    If all is well, I will close the thread in a week's time.
    Meanwhile if any of you have any ideas or experience, please do let me know.

  4. #4
    krag is offline Medium experience
    Windows 10 Office 365
    Join Date
    May 2014
    Posts
    71
    Hi Ajax
    Looks like my post below crossed yours.
    Thanks for your comments.
    I have checked all points mentioned by you already one by one.
    It was only happening when I had the -1* in the code.
    Of course there was no syntax error for the brackets - there are 7 ).
    Anyway, as I posted now, it has started working fine without any corrections done by me.
    Perhaps it was due to the century's record 37 degrees temperature in June in Japan now.

  5. #5
    CJ_London is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,397
    or it could be due to a null value or division by zero somewhere in your data

  6. #6
    krag is offline Medium experience
    Windows 10 Office 365
    Join Date
    May 2014
    Posts
    71
    Hi Ajax
    Today I have been testing the program with various other functions in the project and happy to inform that the error did not recur at all.
    I have even used the same formula in a query to load the initial form data and it has worked well.
    Thanks for your ideas and suggestions.
    With this I will close this thread as solved.

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

Similar Threads

  1. Replies: 22
    Last Post: 04-04-2018, 10:57 AM
  2. Replies: 2
    Last Post: 04-27-2015, 02:23 PM
  3. Replies: 9
    Last Post: 12-08-2012, 04:56 PM
  4. Invalid Procedure Call or Argument
    By Trojnfn in forum Access
    Replies: 2
    Last Post: 10-29-2012, 01:44 PM
  5. Replies: 9
    Last Post: 08-10-2012, 03:10 AM

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