Results 1 to 5 of 5
  1. #1
    George is offline Competent Performer
    Windows 7 64bit Access 2013 64bit
    Join Date
    Feb 2012
    Posts
    295

    Verifying accuracy of string

    Good Day,



    I am using the intermediate window to check the accuracy of a string which I copied from a SQL query window. It returns an error message which I am having difficulty detecting. My code is as follows:

    HTML Code:
    Public Sub Accounts()
        Dim curDatabase As Database
        Dim rst As Recordset
        Dim strSql As String
                        
        strSql = "SELECT Sum([Order Details].Quantity) AS SumOfQuantity," _
        & "[Order Details]. AccountFROM [Order Details]GROUP BY [Order Details].Account," _
        & "[Order Details].[Order ID]HAVING ((([Order Details].[Order ID])=201));"
        
        Debug.Print strSql
        
        Set curDatabase = CurrentDb
        Set rst = curDatabase.OpenRecordset(strSql)
      
       Set rst = Nothing
       Set curDatabase = Nothing
       
    End Sub
    can anyone assist in the detection of my error.

  2. #2
    ranman256's Avatar
    ranman256 is online now VIP
    Windows Vista Access 2010 32bit
    Join Date
    Apr 2014
    Location
    Kentucky
    Posts
    9,521
    why didnt you show us the error line?
    why didnt you tell us the error#?

    if it is in the sql, did you put the sql into a query? It will tell you the error.

  3. #3
    June7's Avatar
    June7 is offline VIP
    Windows 7 64bit Access 2010 32bit
    Join Date
    May 2011
    Location
    The Great Land
    Posts
    52,815
    Looks like copy/paste from query builder with some carriage returns removed causing lines to run together.

    Remove space after dot (.). Need space in front of FROM, in front of GROUP, in front of HAVING. Don't need [Order ID] in the GROUP BY - remove and use WHERE. Simplify.

    strSql = "SELECT Sum(Quantity) AS SumQty, Account FROM [Order Details] WHERE [Order ID]=201 GROUP BY Account;"
    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
    George is offline Competent Performer
    Windows 7 64bit Access 2013 64bit
    Join Date
    Feb 2012
    Posts
    295
    Thanks ranman 256 for your response

    The code was obtained from a query. Here is the error message.

    syntax error (missing operator) in query expression '[Order Detail].AccountFROM [Order Details] GROUP BY [Order Details].Account'

  5. #5
    aytee111 is offline Competent At Times
    Windows 10 Access 2013 64bit
    Join Date
    Nov 2011
    Location
    Nomad
    Posts
    3,936
    Post your latest result from the Debug.Print statement

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

Similar Threads

  1. Replies: 2
    Last Post: 03-27-2017, 05:02 PM
  2. Touble Calculating Accuracy in a Query
    By Gabriel2012 in forum Queries
    Replies: 4
    Last Post: 01-30-2013, 03:14 PM
  3. Verifying duplicate invoice numbers?
    By swaninwa in forum Access
    Replies: 1
    Last Post: 03-27-2012, 04:34 PM
  4. Verifying phone numbers
    By looloo in forum Forms
    Replies: 15
    Last Post: 09-23-2011, 07:38 AM
  5. Enforcing Data Accuracy from FK
    By Minerva in forum Access
    Replies: 3
    Last Post: 02-21-2010, 04:01 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