Page 2 of 2 FirstFirst 12
Results 16 to 20 of 20
  1. #16
    Minty is offline VIP
    Windows 10 Office 365
    Join Date
    Sep 2017
    Location
    UK - Wiltshire
    Posts
    3,003

    I don't think you could have done.
    I changed it to Long integer and then this query works.
    Code:
    SELECT TireData.MyMonth, TireData.Quantity, IIf([quantity]-3=1,"Yes","No") AS Expr1
    FROM TireData;
    I haven't been able to upload a file, for some reason.
    DLookup Syntax and others http://access.mvps.org/access/general/gen0018.htm
    Please use the star below the post to say thanks if we have helped !
    ↓↓ It's down here ↓↓

  2. #17
    DC CS is offline Advanced Beginner
    Windows 11 Office 365
    Join Date
    Jan 2023
    Location
    Vaalpark, South Africa
    Posts
    69
    If I paste the SQL code into a blank query, it works fine, but once I try to amend the code in the query design, I end up with the same result. All that differs is the error message.
    Code:
    SELECT TireData.MyMonth, TireData.Quantity, IIf([quantity]-3=1,1,0) AS Expr1
    FROM TireData;
    Try changing the Expr1 to the above in the query design screen and you end up with an error message saying there is invalid numbers and then highlights ""1,1,0".

  3. #18
    Minty is offline VIP
    Windows 10 Office 365
    Join Date
    Sep 2017
    Location
    UK - Wiltshire
    Posts
    3,003
    I just reloaded your database, and simply edited your query, after setting the field type to long integer.

    Click image for larger version. 

Name:	Screenshot 2023-07-19 151337.png 
Views:	15 
Size:	7.9 KB 
ID:	50505

    It runs:

    Click image for larger version. 

Name:	Screenshot 2023-07-19 151439.png 
Views:	15 
Size:	13.9 KB 
ID:	50506

    Query SQL
    Code:
    SELECT TireData.MyMonth, TireData.Quantity, IIf([quantity]-3=1,"Yes","No") AS Expr1, IIf([quantity]-3=1,1,0) AS Expr2
    FROM TireData;
    As you can see I can edit it and run it and save it.
    There is something else going on somewhere.

    Where is the file stored?
    DLookup Syntax and others http://access.mvps.org/access/general/gen0018.htm
    Please use the star below the post to say thanks if we have helped !
    ↓↓ It's down here ↓↓

  4. #19
    Micron is offline Virtually Inert Person
    Windows 10 Access 2016
    Join Date
    Jun 2014
    Location
    Ontario, Canada
    Posts
    12,801
    Odd - works form me as is (with double). I even added a record with null for qty and still works (as I expected).
    I suspect the table provided is not the one OP is using and there is at least 1 record with an issue - maybe a zls that looks like null.
    @DC CS - is that the table that you're using? If not, provide that one.
    The more we hear silence, the more we begin to think about our value in this universe.
    Paraphrase of Professor Brian Cox.

  5. #20
    DC CS is offline Advanced Beginner
    Windows 11 Office 365
    Join Date
    Jan 2023
    Location
    Vaalpark, South Africa
    Posts
    69
    Hi all,
    Thank you so much for your input, but I finally resolved this.
    It seems that the table got corrupted or something. I deleted the table and re-created it and all is working now as it should.

    Thanks

Page 2 of 2 FirstFirst 12
Please reply to this thread with any new information or opinions.

Similar Threads

  1. SQL Query using IF Statement???
    By bishmedia in forum Queries
    Replies: 13
    Last Post: 05-23-2018, 12:53 PM
  2. Replies: 8
    Last Post: 05-08-2018, 07:27 AM
  3. WHERE statement (between) in a query
    By bignate in forum Queries
    Replies: 2
    Last Post: 09-12-2013, 04:51 AM
  4. if statement in sql statement, query builder
    By 54.69.6d.20 in forum Access
    Replies: 4
    Last Post: 09-11-2012, 07:38 AM
  5. Replies: 3
    Last Post: 07-10-2012, 05:23 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