Results 1 to 8 of 8
  1. #1
    benuva is offline Novice
    Windows 10 Access 2016
    Join Date
    Sep 2018
    Posts
    3

    Access IFF AND


    Merhaba,

    Bunu Access'te nasıl yazarım?


    = EĞER (VE (G5 <> ""; I5 = ""); G5; EĞER (VE (G5 = ""; I5 <> ""); I5; EĞER (VE (G5 <> ""; I5 <> ""); I5 ve "-" & G5)))

  2. #2
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,801
    Please translate into English and post English or both versions so that we don't have to translate. You can then translate English answers.
    Hello there,

    How do I write this in Access?

    Code:
    = IF (AND (G5 <> ""; I5 = ""); G5; IF (AND (G5 = ""; I5 <> ""); I5; IF (AND (G5 <> ""; I5 <> ""); I5 and "-" & G5)))
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  3. #3
    benuva is offline Novice
    Windows 10 Access 2016
    Join Date
    Sep 2018
    Posts
    3
    = IF (AND (G5 <> ""; I5 = ""); G5; IF (AND (G5 = ""; I5 <> ""); I5; IF (AND (G5 <> ""; I5 <> ""); I5 and "-" & G5)))

  4. #4
    benuva is offline Novice
    Windows 10 Access 2016
    Join Date
    Sep 2018
    Posts
    3
    How can I do this in access?

    =IF(AND(G5<>"";I5="");G5;IF(AND(G5="";I5<>"");I5;I F(AND(G5<>"";I5<>"");I5&" - "&G5)))

  5. #5
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,801
    I don't see how you can. Mostly, Access does not have row:column identifiers, so I5 is meaningless. It also does not have an AND function (at least that's my opinion although you may find web pages that say different. In Access, AND is a logical operator like OR, XOR, and maybe BETWEEN and LIKE). The equivalent to IF in Access is IIF. The AND function has to be written as
    (G5<>"" AND I5="")
    You could try to nest several IIF expressions together (like they were IF's) while using syntax like x AND y but nested IIF's drive me to drink, so I rarely do them. Each IIF has 3 parts; expression, value if True and value if false. Also is interesting that you separated your Excel formula with semi colons (. I would have thought that would be a problem.

    Maybe you should post what you have for data, and what result you need from such an expression. No guarantee that I/we can help.
    Last edited by Micron; 09-26-2018 at 03:37 PM. Reason: added info

  6. #6
    June7's Avatar
    June7 is online now VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    Instead of nested IIf(), Switch or Choose might be possible.

    How does this calculation relate to Access? Are you importing data from Excel and now want to do the same calc in Access? What are the field names?

    Maybe:

    =Switch(G5 <> "" And I5 = "", G5, G5 = "" And 15 <> "", I5, True, I5 - G5)

    Substitute appropriate field names for the cell references.

    Or if fields are number type, they cannot hold empty string and therefore testing for empty string is useless. Number fields with no data would be Null.

    =Switch(Not IsNull(G5) And IsNull(I5), G5, IsNull(G5) And Not IsNull(15), I5, True, I5 - G5)

    Or use Nz():

    =Nz(I5,0) - Nz(G5,0)
    Last edited by June7; 09-27-2018 at 02:12 AM.
    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.

  7. #7
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,801
    now cross posted here
    https://www.mrexcel.com/forum/micros...nt-access.html

    Ordinarily I would provide the usual link, but he/she continues to post in Turkish(?) so I don't see the point.

  8. #8
    CJ_London is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Mar 2015
    Posts
    11,430
    How can I do this in access?

    =IF(AND(G5<>"";I5="");G5;IF(AND(G5="";I5<>"");I5;I F(AND(G5<>"";I5<>"");I5&" - "&G5)))
    you can use the switch function or a nested iif

    =iif(G5<>"" AND I5="",G5,iif(G5="" AND I5<>"",I5,I5 & " - " & G5))

    there is no need for the third IF or iif since there are no other options. Replace G5 and I5 with your field names

    you may also need to use the nz function because a blank string could be a ZLS (zero length string - "") or a null

    =iif(nz(G5,"")<>"" AND nz(I5,"")="",G5,iif(nz(G5,"")="" AND nz(I5,"")<>"",I5,I5 & " - " & G5))

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

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