Results 1 to 4 of 4
  1. #1
    Epona is offline Novice
    Windows Vista Access 2007
    Join Date
    Feb 2012
    Location
    South Africa
    Posts
    26

    "Query to complex"

    I am a bit stumped - please help.



    I need to calculate the stock that must be purchased per month over a 12 month period.

    The mathematical formulae is;
    for M2
    IF [M1]>0,[M1]+[M2],[M2]

    M3 would then be
    IF [M2]>0,[M2]+[M3],[M4]

    Then rolling forward till month 12

    The data is organised as a table with each month being a field. My problem is that if I use the IIF stateemnt in the builder when I get to month 10 i get the error "Query to complex".

    Does anyone know if this can be done with a SQL query and if so what would the query be? Or if there is another way of doing this.

    There will be subsequent calcualtions on the fields based on lead times so I need to retain the structure as is if possible.

  2. #2
    Robeen is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    Mar 2011
    Location
    Tulsa, Oklahoma.
    Posts
    1,596
    I'm not sure if you've considered this already, but you could create a function [VBA] that does all your logic.
    You can pass your function the Month [M2, M3 . . .] and have it return the relevant data to you.
    I'm not sure I understand exactly what you need to do but . . .
    Your function might look something like this:

    Code:
     
    Function MonthInfo(MonthName as String) As Double
     
    Dim MthNm as String
     
    MthNm = MonthName
     
    Select Case MthNm 
         Case "M1" 
              'Do something here . . .
         Case "M2"
              'Do something here . . .
    End Select
     
    End Function
    In the Query, your field will look something like this:
    FieldName: MonthInfo(MonthName)

    I'm not sure I have totally understood your scenario - but you might be able to take what I've given you and run with it.

    Let me know if you have questions.

  3. #3
    Epona is offline Novice
    Windows Vista Access 2007
    Join Date
    Feb 2012
    Location
    South Africa
    Posts
    26
    Thanks, that looks promising - let me see if I can get it to work

  4. #4
    Robeen is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    Mar 2011
    Location
    Tulsa, Oklahoma.
    Posts
    1,596
    I made a change to my post:
    FieldName: MonthInfo(MonthName)

    Let us know how it goes!! All the best.

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

Similar Threads

  1. Replies: 3
    Last Post: 12-30-2011, 12:43 PM
  2. Complex "sumif" style formula
    By groonpooch in forum Queries
    Replies: 3
    Last Post: 12-16-2011, 07:05 PM
  3. Replies: 16
    Last Post: 07-22-2011, 09:23 AM
  4. Complex Table "Lookup" Lists
    By Rawb in forum Access
    Replies: 19
    Last Post: 03-01-2011, 02:52 PM
  5. WHERE clause "too complex"
    By Ted C in forum Queries
    Replies: 4
    Last Post: 06-30-2010, 12:08 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