Results 1 to 6 of 6
  1. #1
    anilytics is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Feb 2012
    Location
    London
    Posts
    11

    UPDATE TO IIF Statement

    Hello all once again....



    Ok I have 2 tables which structured identically but with different naming convention.

    Table 1 - Is new data
    Table 2 - Updated table

    So Table 2 has values in there some of the values have been fixed since the begginging of the year.
    Table 1 is where users use to input new values.

    What I need to do in an update query with a lot of IIF statements depending on the values.

    There are these 3 statements:

    1) IIF Table 2 >= Table 1 VALUE = REMAIN AS Table 2
    2) IIF Table 1 = Blank or 0 VALUE = REMAIN AS Table 2
    3) IIF Table 1 >= Table 2 VALUE = Table 1

    So I have had a few attempts:

    Attempt 1:
    IIf([forecast_channels].[forecastsales]>=[mro_tblchanwave].[respforecast],[forecast_channels].[forecastsales],[mro_tblchanwave].[respforecast])

    Attempt 2:
    IIf([forecast_channels].[forecastsales]>=[mro_tblchanwave].[respforecast],[forecast_channels].[forecastsales]) or IIF(not isnull([mro_tblchanwave].[respforecast],[forecast_channels].[forecastsales])) IIF ([mro_tblchanwave].[respforecast]>[forecast_channels].[forecastsales],[mro_tblchanwave].[respforecast]))


    Attempt 3:
    IIF([forecast_channels].[forecastsales]>=[mro_tblchanwave].[respforecast] OR IIF(not isnull(mro_tblchanwave].[respforecast],[forecast_channels].[forecastsales])), IIF([mro_tblchanwave].[respforecast] > [forecast_channels].[forecastsales],[mro_tblchanwave].[respforecast]))



    But not much luck in making all 3 work!

    your help would be appreciated!


    Anil

  2. #2
    June7's Avatar
    June7 is offline VIP
    Windows XP Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,626
    Missing the closing paren for the IsNull function.

    Try:

    IIF([forecast_channels].[forecastsales]>=[mro_tblchanwave].[respforecast] OR Not IsNull(mro_tblchanwave].[respforecast]),[forecast_channels].[forecastsales], IIF([mro_tblchanwave].[respforecast] > [forecast_channels].[forecastsales],[mro_tblchanwave].[respforecast], "alternate value here"))

    or:

    IIF([forecast_channels].[forecastsales]>=[mro_tblchanwave].[respforecast] OR Not IsNull(mro_tblchanwave].[respforecast]),[forecast_channels].[forecastsales], [mro_tblchanwave].[respforecast])
    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.

  3. #3
    anilytics is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Feb 2012
    Location
    London
    Posts
    11
    Thanks for the update.... I have added another "Or Not Isnull" to the second IIF parameter but still no luck it just does not want to update... even testing by adding a value higher than the other table.... I have inserted some snapshots of the two tables and the update query table and the new IIF statement syntax....

    Click image for larger version. 

Name:	tbl_mrotblchanwave.jpg 
Views:	3 
Size:	22.3 KB 
ID:	6691Click image for larger version. 

Name:	updatequery.jpg 
Views:	4 
Size:	96.9 KB 
ID:	6692


    The new IIF Syntax is:

    IIf([forecast_channels].[forecastsales]>=[mro_tblchanwave].[respforecast] Or Not IsNull([mro_tblchanwave].[respforecast]),[forecast_channels].[forecastsales],IIf([mro_tblchanwave].[respforecast]>=[forecast_channels].[forecastsales] Or Not IsNull([forecast_channels].[forecastsales]),[mro_tblchanwave].[respforecast],[forecast_channels].[forecastsales]))
    Attached Thumbnails Attached Thumbnails tbl_forecast_channels.jpg  

  4. #4
    anilytics is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Feb 2012
    Location
    London
    Posts
    11
    I have also taken out the "Or Not Isnull" and still no joy....

    IIf([forecast_channels].[forecastsales]>=[mro_tblchanwave].[respforecast],[forecast_channels].[forecastsales],IIf([mro_tblchanwave].[respforecast]>=[forecast_channels].[forecastsales],[mro_tblchanwave].[respforecast],[forecast_channels].[forecastsales]))

  5. #5
    anilytics is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Feb 2012
    Location
    London
    Posts
    11
    I changed:

    IIf([forecast_channels].[forecastsales]>=[mro_tblchanwave].[respforecast],[forecast_channels].[forecastsales],IIf([mro_tblchanwave].[respforecast]>=[forecast_channels].[forecastsales],[mro_tblchanwave].[respforecast],[forecast_channels].[forecastsales]))

    To

    IIf([forecast_channels].[forecastsales]>=[mro_tblchanwave].[respforecast],[forecast_channels].[forecastsales],IIf([mro_tblchanwave].[respforecast]>=[forecast_channels].[forecastsales],[mro_tblchanwave].[respforecast],"0"))

    And when i run the update it produces the false answer which is "0". But when I then enter in figures into the table that gets updated by another system then run the update it works???

  6. #6
    anilytics is offline Novice
    Windows 7 32bit Access 2010 32bit
    Join Date
    Feb 2012
    Location
    London
    Posts
    11
    Problem solved i used the following

    IIf([forecast_channels].[forecastsales]>=[mro_tblchanwave].[respforecast],[forecast_channels].[forecastsales],IIf([mro_tblchanwave].[respforecast]>[forecast_channels].[forecastsales],[mro_tblchanwave].[respforecast],[forecast_channels].[forecastsales]))

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

Similar Threads

  1. Replies: 2
    Last Post: 02-22-2012, 07:14 AM
  2. SQL Update statement help
    By kalltim in forum Access
    Replies: 6
    Last Post: 01-18-2012, 07:30 AM
  3. Syntax error in UPDATE statement HELP!
    By asmith78 in forum SQL Server
    Replies: 5
    Last Post: 09-07-2011, 05:50 PM
  4. Replies: 2
    Last Post: 07-20-2011, 02:01 PM
  5. UPDATE Statement Correct Syntax
    By OMGsh Y did I say Yes in forum Forms
    Replies: 2
    Last Post: 02-23-2011, 01:42 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