Results 1 to 4 of 4
  1. #1
    Mary87 is offline Novice
    Windows 8 Access 2007
    Join Date
    Jan 2015
    Posts
    13

    Argument not Optional Error when creating a formula to run when clicking on a field On Click: [Event

    Please can you assist.

    I have spent 2 days trying to debug....

    Just a brief introduction to the problem.

    I have created a form in MS Access 2010, the fields feed into a table "Cost Saving Tracker" form.
    This forms calculates the amount of cost savings for the fiscal year ( from the start date to the end date (start date +720 days).

    The cost saving amount depends on the field "One off or Recurring Cost Saving". The Fiscal Year starts on Oct and ends November. If it is a Recurring Cost Saving the Cost saving must be split accordingly.

    For example if the start date is 01/09/2015 (Fiscal Month 11) and the end date being (01/09/2015 + 720 days=16/08/2018).
    Cost Saving Amount = 150000
    Monthly Cost Saving - 12500 (150000/12).

    Then the Calculations should be as follow:
    Fiscal Year 2015= 137500
    Fiscal Year 2016= 150000
    Fiscal Year 2017= 12500 (with the first and last year reconciling back to the Cost Saving Amount). The last year calculation being (Fiscal Month-12)*-1.

    The way I have approached this is as follows, I created a form
    1. Add Existing Fields
    2. Added the Fiscal Year Saving 2015 from the table.
    3. Right Click to view properties.
    4. Click on the "Event" tab and created an On Click: [Event Procedure]
    5. The formula being = IIf([One Off or Recurring Cost Saving] = "Recurring Cost Saving", IIf(Year([cboDate]) = 2015, [Monthly Cost Saving CAD] * IIf(Month([cboDate]) - 10 < 0, Month([cboDate]) + 2, IIf(Month([cboDate]) - 10 = 0,12, Month([cboDate]) - 10)),IIf(Year([cboDate] + 720) = 2015, ((IIf(Month([cboDate]) - 10 < 0, Month([cboDate]) + 2, IIf(Month([cboDate]) - 10 = 0, 12, Month([cboDate]) - 10)) - 12) * -1 * [Monthly Cost Saving CAD]),[Cost Saving Equivalent CAD]))) .


    When trying to update the field. I would receive the following error "Compile error: Argument not optional".

    However this formula works in Excel.



    Thanks

  2. #2
    John_G is offline VIP
    Windows 7 32bit Access 2010 32bit
    Join Date
    Oct 2011
    Location
    Ottawa, ON (area)
    Posts
    2,615
    I think The first IIf in the formula is missing a "Value if False", which would be in the very end of the formula somewhere. You will have to carefully deconstruct the statement to find out where you need it.

  3. #3
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,899
    Does not appear to be "Value if False" parameter for either:

    IIf(Year([cboDate]) = 2015

    IIf(Year([cboDate] + 720) = 2015

    Suggest you build up the expression in stages. Start with:

    IIf(a, b, c)

    Build each a, b, c term independently then substitute.
    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.

  4. #4
    Mary87 is offline Novice
    Windows 8 Access 2007
    Join Date
    Jan 2015
    Posts
    13
    Thank you , it is working.

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

Similar Threads

  1. Replies: 4
    Last Post: 08-08-2013, 12:10 PM
  2. error argument not optional
    By slimjen in forum Programming
    Replies: 10
    Last Post: 03-20-2013, 09:31 PM
  3. Compile Error: Argument not optional
    By tariq1 in forum Programming
    Replies: 4
    Last Post: 08-11-2012, 01:06 PM
  4. Replies: 7
    Last Post: 11-17-2011, 02:56 PM
  5. Compile Error: Argument Not Optional
    By bg18461 in forum Access
    Replies: 1
    Last Post: 12-01-2010, 08:47 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