Results 1 to 5 of 5
  1. #1
    Derrick T. Davidson is offline Competent Performer
    Windows 8 Access 2010 64bit
    Join Date
    Mar 2013
    Posts
    142

    Error subtracting

    I have a query that deducts a number from another number and gives me the difference:
    Actual Hours: [tblClientBookingForm]![ActualReturnTime]-[tblClientBookingForm]![ActualPickTime]
    i.e. 19.09 - 9.00 result 10.09



    I then do another query that "should" deduct a number from the result i.e. 10.09 - 8.00 result "should" be 2.09
    Expr16: [Actual Hours]-[HoursBooked]

    I am using number format not date format in all the entries, but when I execute I get the error message below:

    "Syntax error (missing operator) in query expression 'Actual Hours - [tblClientBookingForm].[HoursBooked]

    What am I doing wrong ????

  2. #2
    stmoong is offline Competent Performer
    Windows XP Access 2007
    Join Date
    Sep 2011
    Location
    Singapore
    Posts
    108
    Either use another query to form the final query. Your first query will have the [Actual Hours] computed. The final query will be able to make use of the [Actual Hours]

    Otherwise, you can just use a long formula like so:
    [tblClientBookingForm]![ActualReturnTime]-[tblClientBookingForm]![ActualPickTime]-[tblClientBookingForm].[HoursBooked]

  3. #3
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,643
    Why 'another' query if all the fields are in the same table?

    SELECT [ActualReturnTime]-[ActualPickTime] AS ActualHours, [ActualHours]-[HoursBooked] AS HrsDiff;
    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. #4
    Derrick T. Davidson is offline Competent Performer
    Windows 8 Access 2010 64bit
    Join Date
    Mar 2013
    Posts
    142
    Please do not be angry I am a novice here, where do I enter the above as when I try to put into an expression I get an error message "Invalid syntax you may have entered an operand without an operator"

  5. #5
    June7's Avatar
    June7 is online now VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    53,643
    That is the statement for a query as shown in the SQL View window of query builder - but I forgot to finish it.

    SELECT [ActualReturnTime]-[ActualPickTime] AS ActualHours, [ActualHours]-[HoursBooked] AS HrsDiff FROM tblClientBookingForm;

    Access Help has guidelines on using the query builder and constructing calculated fields in query.
    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. vba > subtracting time
    By metokushika in forum Access
    Replies: 2
    Last Post: 12-09-2014, 09:17 PM
  2. Subtracting two records
    By laipeka in forum Queries
    Replies: 2
    Last Post: 08-30-2012, 04:12 AM
  3. Adding/Subtracting
    By JayX in forum Programming
    Replies: 3
    Last Post: 12-15-2011, 03:13 PM
  4. Subtracting Fields
    By zakslaher in forum Access
    Replies: 15
    Last Post: 03-30-2010, 09:36 AM
  5. Subtracting Records
    By e13851mlee in forum Programming
    Replies: 1
    Last Post: 12-17-2009, 04:50 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