Results 1 to 4 of 4

Thread: Problem with select From Clause

  1. #1
    Join Date
    Jul 2010
    Posts
    5

    Problem with select From Clause

    I am having problem with the select statement of this code, for some reason when I ran this project it comes bact with this error message syntax error in From Clause, and it highlights this line of code rs.Open StrSQL, ad, adOpenDynamic, adLockOptimistic, adCmdText
    Thanks for your help
    _al
    ************************************************** ********************************************



    Private Sub Form_Load()
    Dim StrSQL As String
    'Open a database connection
    Dim rs As ADODB.Recordset
    Dim ad As ADODB.Connection
    Set ad = New ADODB.Connection
    ad.Provider = "Microsoft.ACE.OLEDB.12.0"
    'ad.ConnectionString = "Data Source=C:\TripLogDesign\Triplogmdb.accdb"
    ad.ConnectionString = "Data Source=C:\TripLogDesign\TripLogmdb.accdb"
    ad.Open
    Set rs = New ADODB.Recordset
    StrSQL = "SELECT T.CompanyName FROM Triplogtbl" & _
    "WHERE CampanyName IS NOT NULL"
    rs.Open StrSQL, ad, adOpenDynamic, adLockOptimistic, adCmdText
    If Not rs.BOF And Not rs.EOF Then
    txtCompanyName.Text = rs.Fields("CompanyName").Value
    End If
    rs.Close
    Set rs = Nothing
    ad.Close
    Set ad = Nothing
    End Sub

  2. #2
    Join Date
    Mar 2006
    Location
    Oklahoma City, OK
    Posts
    184
    Try this SQL:

    Code:
     
    
    strSQl = "SELECT T.CompanyName FROM Triplogtbl as T " & _
        "WHERE CampanyName IS NOT NULL;"
    or

    Code:
     
    
    strSQl = "SELECT Triplogtbl.CompanyName FROM Triplogtbl " & _
        "WHERE CampanyName IS NOT NULL;"
    Boyd Trimmell aka HiTech Coach
    Microsoft MVP - Access Expert
    [SIGPIC][/SIGPIC]
    Office Programming 25+ years as a Software Developer specializing in:
    Business Process Management
    Accounting/Inventory Control
    Customer Relations Management (CRM)
    Electronic Data Interchange (EDI)

  3. #3
    Join Date
    Jul 2010
    Posts
    5
    Thanks HiTechCoach, You are highly appreciated

  4. #4
    Join Date
    Mar 2006
    Location
    Oklahoma City, OK
    Posts
    184
    Quote Originally Posted by alobi View Post
    Thanks HiTechCoach, You are highly appreciated
    You're welcome!

    Glad I could assist.
    Boyd Trimmell aka HiTech Coach
    Microsoft MVP - Access Expert
    [SIGPIC][/SIGPIC]
    Office Programming 25+ years as a Software Developer specializing in:
    Business Process Management
    Accounting/Inventory Control
    Customer Relations Management (CRM)
    Electronic Data Interchange (EDI)

Posting Permissions

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