Results 1 to 5 of 5
  1. #1
    carmenv323 is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Oct 2021
    Location
    Massachusetts
    Posts
    78

    IIF statements where Is Not Null

    Hello, I have the following on a form to update a field on a form, but I want to make it an Update Query instead. I've tried using the Builder option but haven't been successful. Any ideas on how to translate this in a query?



    If IsNull(Me.Underground) And IsNull(Me.Overhead) Then
    Me.SCOPECAT = Me.Station
    ElseIf IsNull(Me.Station) And IsNull(Me.Overhead) Then
    Me.SCOPECAT = Me.Underground
    ElseIf IsNull(Me.Station) And IsNull(Me.Underground) Then
    Me.SCOPECAT = Me.Overhead
    End If

  2. #2
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    I think you have a design problem, but you could use nested IIf() functions. Are two of those fields always Null? If so, there should probably be a single field.
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

  3. #3
    carmenv323 is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Oct 2021
    Location
    Massachusetts
    Posts
    78
    There is just one field in the table that I want to append but I used a MS Form and I could only use the three options to branch out, now I need to add it to the correct field only if it's not null.

    I created three separate tables for each of the options and working on trying to nest but it's still the same issue where I don't get any results

  4. #4
    June7's Avatar
    June7 is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    If you try to run an UPDATE action SQL on a record that is already in edit mode on form, it will trigger conflict error.

    Why save SCOPECAT to table? Its value is dependent on other data and can be calculated when needed.

    Why do you want to use UPDATE action SQL?

    Not really understanding the schema. If you want to provide db for review, follow instructions at bottom of my post.
    Last edited by June7; 02-29-2024 at 04:41 PM.
    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.

  5. #5
    pbaldy's Avatar
    pbaldy is offline Who is John Galt?
    Windows XP Access 2007
    Join Date
    Feb 2010
    Location
    Nevada, USA
    Posts
    22,521
    Posting the db may reveal design issues that will plaque you down the road. Better to fix them early than live with them forever.

    If the design is set, did you try the nested IIf()?
    Paul (wino moderator)
    MS Access MVP 2007-2019
    www.BaldyWeb.com

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

Similar Threads

  1. Replies: 3
    Last Post: 03-09-2021, 08:44 AM
  2. Replies: 2
    Last Post: 10-07-2019, 10:46 AM
  3. Replies: 4
    Last Post: 03-11-2017, 09:48 PM
  4. Replies: 7
    Last Post: 11-07-2016, 09:24 AM
  5. Replies: 1
    Last Post: 02-23-2012, 02:27 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