Page 2 of 2 FirstFirst 12
Results 16 to 21 of 21
  1. #16
    andy49's Avatar
    andy49 is offline VIP
    Windows 10 Access 2010 64bit
    Join Date
    Nov 2016
    Location
    London
    Posts
    1,051
    I can't replicate the error using your SQL.


    All my fields are in Table 1 and they are all text fields



    Can you confirm this is the case with your fields

  2. #17
    CP611 is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Nov 2017
    Posts
    57
    Hi,

    The ones in Bold are new fields that I am adding but the fields that I am selecting from Table1 are all currently text fields. I have a lot more columns but didn't add those in as that would be very long, I have the same problem further along whenever I try to add a statement with a comma in. It will let me type the IIF statement in, I only get the query when I try to run it

  3. #18
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,644
    You are able to create and save the query object but it errors when you try to open? Very bizarre, never encountered this issue. Can you try the db on another computer?
    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.

  4. #19
    CP611 is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Nov 2017
    Posts
    57
    I can create the query, but I can't save or run it. I haven't tried it on another computer but I could try. It's very frustrating!!

  5. #20
    ssanfu is offline Master of Nothing
    Windows 7 32bit Access 2010 32bit
    Join Date
    Sep 2010
    Location
    Anchorage, Alaska, USA
    Posts
    9,664
    This is the actual SQL?
    Code:
    SELECT 
    Null AS SERIALNUMBER, 
    Null AS CONTACTTYPE, 
    Null AS TITLE,  
    [Table1].[First Name], 
    [Table1].[Last Name],
    [Table1].Address & "|"  & [Address2] AS [=Expr],   '<<-- WHAT??? Probably invalid name. Change the pipe to a dash
    [Table1].[Suburb/City], 
    [Table1].County,  
    [Table1].[Postal Code],
     [Table1].Country,  
    IIf([Gender]="F","Female","Male") AS Expr
    FROM Table1;
    I would use/try
    Code:
    SELECT 
    Null AS SERIALNUMBER, 
    Null AS CONTACTTYPE, 
    Null AS TITLE,  
    [Table1].[First Name], 
    [Table1].[Last Name],
    [Table1].Address & " - "  & [Address2] AS StreetAddress,     '<- set name as StreetAddress 
    [Table1].[Suburb/City], 
    [Table1].County,  
    [Table1].[Postal Code],
     [Table1].Country,  
    IIf([Gender]="F","Female","Male") AS Expr1   '<- added the 1
    FROM Table1;
    I would also recommend removing the spaces and special characters in the field names. Use only letters and numbers (exception is the underscore)

  6. #21
    CP611 is offline Advanced Beginner
    Windows 10 Access 2016
    Join Date
    Nov 2017
    Posts
    57
    Thank you. It worked in the end, if I didn't select the table from which is was supposed to come from, happy days!

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

Similar Threads

  1. Error with Query based on IIF statements
    By tylerpickering in forum Queries
    Replies: 2
    Last Post: 06-17-2014, 02:36 PM
  2. Replies: 11
    Last Post: 05-01-2014, 11:56 AM
  3. Mysterious date syntax error message
    By Monterey_Manzer in forum Queries
    Replies: 12
    Last Post: 12-23-2013, 06:56 PM
  4. Replies: 3
    Last Post: 03-05-2013, 11:17 AM
  5. Replies: 6
    Last Post: 05-30-2012, 12:32 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