Results 1 to 4 of 4

Thread: Error in From Cluase

  1. #1

    Thread Starter
    Fanatic Member
    Join Date
    Oct 2003
    Location
    Portville NY
    Posts
    780

    Error in From Cluase

    i have an error in this from clause, i'm not really sure why it is. but here is the code.
    VB Code:
    1. '****************************************************
    2. 'the form loads with a connection the Test Query in
    3. 'access
    4. Private Sub Form_Load()
    5. If sgrs.State = adStateClosed Then
    6.     Debug.Print "sgrs is closed"
    7.     sgrs.Open "SELECT * FROM Test", DBConn, adOpenDynamic, adLockOptimistic
    8.     Call Display(0)
    9.     sgrs.MoveFirst
    10. Else
    11.     Debug.Print "Sgrs is open"
    12.     Call Display(0)
    13. End If
    14. If Trs.State = adStateClosed Then
    15.     Debug.Print "trs is closed"
    16.     Trs.Open "SELECT * FROM Check", DBConn, adOpenDynamic, adLockOptimistic
    17. End If
    18. End Sub
    Trs and sgrs are both declared in the heading as global variables. i need to access both of the tables in order to get info from both of them. the tables are in Access97

  2. #2
    Don't Panic! Ecniv's Avatar
    Join Date
    Nov 2000
    Location
    Amsterdam...
    Posts
    5,343

    Re: Error in From Cluase

    Originally posted by Dubya007
    i have an error in this from clause, i'm not really sure why it is. but here is the code.
    VB Code:
    1. '****************************************************
    2. 'the form loads with a connection the Test Query in
    3. 'access
    4. Private Sub Form_Load()
    5. If sgrs.State = adStateClosed Then
    6.     Debug.Print "sgrs is closed"
    7.     sgrs.Open "SELECT * FROM Test", DBConn, adOpenDynamic, adLockOptimistic[color=red], adCmdText[/color]
    8.     Call Display(0)
    9.     sgrs.MoveFirst
    10. Else
    11.     Debug.Print "Sgrs is open"
    12.     Call Display(0)
    13. End If
    14. If Trs.State = adStateClosed Then
    15.     Debug.Print "trs is closed"
    16.     Trs.Open "SELECT * FROM Check", DBConn, adOpenDynamic, adLockOptimistic[color=red], adCmdText[/color]
    17. End If
    18. End Sub
    Trs and sgrs are both declared in the heading as global variables. i need to access both of the tables in order to get info from both of them. the tables are in Access97
    Not sure.
    Whats the exact error?
    Add in the parts in red, if the objects are recordsets.


    Vince

    BOFH Now, BOFH Past, Information on duplicates

    Feeling like a fly on the inside of a closed window (Thunk!)
    If I post a lot, it is because I am bored at work! ;D Or stuck...
    * Anything I post can be only my opinion. Advice etc is up to you to persue...

  3. #3

    Thread Starter
    Fanatic Member
    Join Date
    Oct 2003
    Location
    Portville NY
    Posts
    780
    i get an error that says: "Syntax error in FROM clause"
    then the debugger highlights the from clause where this statement is:
    VB Code:
    1. Trs.Open "SELECT * FROM Check", DBConn, adOpenDynamic, adLockOptimistic
    yes they are supposed to be recordsets but can i ask what the parts in red are? i am new to all of this. but thanx for the help

  4. #4
    PowerPoster
    Join Date
    Oct 2002
    Location
    British Columbia
    Posts
    9,758
    Check may be a reserved/key word. Surround it with square brackets or change the table name.

    Select * From [Check]

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