Results 1 to 7 of 7
  1. #1
    kennethnaga is offline Novice
    Windows 10 Access 2016
    Join Date
    Oct 2019
    Posts
    24

    Question Query Error (See Table)



    Index&Facility Reporting Year SCUs Balance Previous Balance
    101A 2019 5000 4000
    101B 2019 4500 3500
    101A 2018 4000 -
    101B 2018 3500 -

    Expression:

    Previous Balance: DLookUp("Balance SCUs","[tbl_Sch2_Summary]","[tbl_Sch2_Summary].[Index&Facility] = '" & [tbl_Sch2_Summary].[Index&Facility] & "' And [tbl_Sch2_Summary].[Reporting Year] = " & [tbl_Sch2_Summary].[Reporting Year]-1)

    Error: Syntax error (missing operator) in query expression 'Balance SCUs'.

    Hi, I'm trying to make a query which cross-checks values, in this case it's the balance field. In the previous balance field, I want to display the balance from the previous year for a particular Facility ID. In Excel, the SUMIFS function was used, but as far as I'm aware this does not exist in Access. Any help regarding this issue is greatly appreciated and if anything is unclear please let me know, thank you!

    The pattern of FacilityID and Reporting Year is not consistent (does not alternate back and forth between 101A and 101B as shown).

    Edit: I know I shouldn't have symbols/spaces in object names, I'm working on an existing dB that I did not create. Thank you!

  2. #2
    Gicu's Avatar
    Gicu is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jul 2015
    Location
    Kelowna, BC, Canada
    Posts
    4,122
    Maybe its just a mistake here in the forum but you have the field name reversed in the dlookup (should be [SCUs Balance] not [Balance SKUs]).

    Cheers
    Vlad Cucinschi
    MS Access Developer
    http://forestbyte.com/

  3. #3
    kennethnaga is offline Novice
    Windows 10 Access 2016
    Join Date
    Oct 2019
    Posts
    24
    Yea it's just a mistake in the post

  4. #4
    Bob Fitz's Avatar
    Bob Fitz is offline Access Developer
    Windows 10 Access 2016
    Join Date
    May 2011
    Location
    Essex UK
    Posts
    3,544
    If this helped, please click the star at the bottom left of this posting and add to my reputation . Many thanks.
    Bob Fitzpatrick

  5. #5
    kennethnaga is offline Novice
    Windows 10 Access 2016
    Join Date
    Oct 2019
    Posts
    24
    Thanks for the link, promise not to do it again

  6. #6
    Gicu's Avatar
    Gicu is offline VIP
    Windows 10 Access 2010 32bit
    Join Date
    Jul 2015
    Location
    Kelowna, BC, Canada
    Posts
    4,122
    Looks like the Reporting year is left-aligned, is the data type text (if yes you need to wrap it in single quotes as well).

    Cheers,
    Vlad Cucinschi
    MS Access Developer
    http://forestbyte.com/

  7. #7
    kennethnaga is offline Novice
    Windows 10 Access 2016
    Join Date
    Oct 2019
    Posts
    24
    Reporting year is number type (not like the table)

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

Similar Threads

  1. ALTER TABLE query syntax error
    By Sck in forum Queries
    Replies: 3
    Last Post: 09-07-2018, 01:01 PM
  2. Getting Error when query table
    By Muzokh in forum Access
    Replies: 2
    Last Post: 04-28-2017, 10:07 AM
  3. Error on Make Table Query
    By DaveC in forum Access
    Replies: 4
    Last Post: 10-01-2014, 11:06 AM
  4. Replies: 2
    Last Post: 05-27-2011, 05:55 AM
  5. Replies: 10
    Last Post: 02-02-2011, 05:48 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