Results 1 to 6 of 6
  1. #1
    RogerD is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Dec 2014
    Location
    Ky
    Posts
    27

    Syntax Error (missing operator) in query expression

    the code below works perfectly. When I designed the database, I added 8 extra columns for future use. We now need to use all 8 of the columns that were in the db, but weren't used for anything.
    SELECT PartsList.MODELNAME, temp.[model number], PartsList.Paper, PartsList.PcsPerPaper, temp.[production line] AS Line, temp.[date time], temp.[production quantity2], (Abs(([production quantity2]*1000))) AS ProdQty, DateValue([date time]) AS [Date], temp.[special notes], PartsList.MfrModel, PartsList.Box, PartsList.PcsPerBox


    FROM temp LEFT JOIN PartsList ON temp.[model number] = PartsList.Post;

    when I add the "PartsList.Extra1, PartsList.PcsPer1" to the query as below, I receive the error message, "Syntax Error (missing operator) in query expression 'model number'".
    If I remove the added items, the query runs as it should.

    SELECT PartsList.MODELNAME, temp.[model number], PartsList.Paper, PartsList.PcsPerPaper, temp.[production line] AS Line, temp.[date time], temp.[production quantity2], (Abs(([production quantity2]*1000))) AS ProdQty, DateValue([date time]) AS [Date], temp.[special notes], PartsList.MfrModel, PartsList.Box, PartsList.PcsPerBox, PartsList.Extra1, PartsList.PcsPer1
    FROM temp LEFT JOIN PartsList ON temp.[model number] = PartsList.Post;


    Any help is appreciated.

  2. #2
    ranman256's Avatar
    ranman256 is offline VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,525
    it may be the parens around the ABS, just use:
    Abs([production quantity2])*1000 as ProdQty

  3. #3
    RogerD is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Dec 2014
    Location
    Ky
    Posts
    27
    Abs(([production quantity2]*1000)) AS ProdQty
    I just tried that
    same error message.

    When we decided we needed to use the extra columns I had added to the table upon building, I had to change the format of 4 of the fields from short text to number. The number format is the same number format as other items in the table.

    I even tried re-writing the query from scratch, removing all existing calculated fields, and still received the same error message.

  4. #4
    RogerD is offline Novice
    Windows 7 64bit Access 2010 64bit
    Join Date
    Dec 2014
    Location
    Ky
    Posts
    27
    I have changed "Model Name" to "ModelName" and "Model Number to "ModelNumber" using the "AS" statement. that appears to have resolved my issue.
    why is that?

  5. #5
    JoeM is offline VIP
    Windows 7 32bit Access 2007
    Join Date
    Jun 2012
    Posts
    3,904
    Not sure. It should work if you place square brackets around the field name.
    That being said, it is usually best practice to NOT use any spaces in your field or object names. It avoids a lot of issues. Many people will use underscores instead of spaces.

  6. #6
    June7's Avatar
    June7 is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,929
    Also, Date is a reserved word. Should not use reserved words as names for anything.
    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.

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

Similar Threads

  1. Replies: 9
    Last Post: 05-20-2016, 09:07 AM
  2. Replies: 4
    Last Post: 03-16-2016, 12:24 PM
  3. Replies: 2
    Last Post: 02-17-2014, 10:27 AM
  4. Replies: 1
    Last Post: 06-02-2013, 04:34 AM
  5. Replies: 9
    Last Post: 01-22-2013, 04:23 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