Results 1 to 3 of 3

Thread: [RESOLVED] Syntax error in FROM clause Error Msg

  1. #1

    Thread Starter
    Addicted Member
    Join Date
    Sep 2005
    Posts
    200

    Resolved [RESOLVED] Syntax error in FROM clause Error Msg

    I have a VB6 program that interfaces with a MS Access 2002 database. I am getting a "Runtime Error '2147217900 (80040e14)' Syntax error in FROM clause". I am out putting the sql in a message box and it is: SELECT * FROM [ALTER] WHERE [PROD] = 292611 I have verified that the product number 292611 is, in fact, in the Alter table of the CycleCount database. I looked for this code on the internet and I kept getting back that somehow it came across a NULL value. If anyone can help I would be greatly appreciative. Here's my code:

    VB Code:
    1. '*INALTER()********************************************************************
    2. 'Name: inALTER()
    3. 'Desc: Returns true if the item is in the ALTER table, false otherwise
    4. Private Function inAlter(PROD As Double) As Boolean
    5.     Dim sql As String
    6.    
    7.     Set newConnection = New ADODB.connection
    8.     newConnection.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0;" & _
    9.         "Data Source= C:\Documents and Settings\p6b0438\My Documents\CycleCount\DB\CycleCount.mdb"
    10.     newConnection.Open
    11.     Set newRecordSet = New ADODB.recordSet
    12.    
    13.     sql = "SELECT * " & _
    14.           "FROM [ALTER] " & _
    15.           "WHERE [PROD] = " & PROD
    16. MsgBox (sql)
    17.     newRecordSet.Open sql, newConnection, adOpenKeyset, adLockPessimistic, adCmdTable
    18. Debug.Print sql
    19.    
    20.     If (newRecordSet.RecordCount > 0) Then
    21.         inAlter = True
    22.     ElseIf (newRecordSet.RecordCount = 0) Then
    23.         inAlter = False
    24.     Else
    25.         MsgBox ("INALTER(): Unable to retrieve data.")
    26.         Exit Function
    27.     End If
    28.    
    29.     newRecordSet.Close
    30.     newConnection.Close
    31.     Set newRecordSet = Nothing
    32.     Set newConnection = Nothing
    33. End Function
    34. '*ENDOF*INALTER()**************************************************************

    Nenio foriras ĝis ĝi havas instru ni kiu ni devas scii.

  2. #2
    PowerPoster
    Join Date
    Oct 2002
    Location
    British Columbia
    Posts
    9,758

    Re: Syntax error in FROM clause Error Msg

    When opening the recordset, you need to specify adCmdText not adCmdTable.

    When you use adCmdTable, the Source argument must be a Table name not a SQL statement.

  3. #3

    Thread Starter
    Addicted Member
    Join Date
    Sep 2005
    Posts
    200

    Re: Syntax error in FROM clause Error Msg

    Now that's embarassing, I should have known that. Thanks!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width