-
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
-
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)
-
Thanks HiTechCoach, You are highly appreciated
-
Originally Posted by alobi
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
-
Forum Rules
|
|