vba sql problem (1 Viewer)

Jaye7

Registered User.
Local time
Today, 18:49
Joined
Aug 19, 2014
Messages
205
I have the following script to run sql via a commandbutton but I keep getting a runtime error which says - A runsql action requires an argument consisting of an sql statement

Code:
 Sub test1()
Dim strsql As String
 strsql = "SELECT ContactT.*, CustomerT.FirstName, CustomerT.LastName, Trim([FirstName] & "" "" & [LastName]) AS FullName, CustomerT.CompanyName, CustomerT.Phone " & _
"FROM CustomerT INNER JOIN ContactT ON CustomerT.CustomerID = ContactT.CustomerID " & _
"WHERE (((CustomerT.FirstName)=""joe""));"
 DoCmd.RunSQL strsql
 
End Sub
 

jdraw

Super Moderator
Staff member
Local time
Today, 04:49
Joined
Jan 23, 2006
Messages
15,393
RunSQL is for Action queries

APPEND, UPDATE, DELETE

You have a SELECT query which is NOT an Action query.
 

Jaye7

Registered User.
Local time
Today, 18:49
Joined
Aug 19, 2014
Messages
205
Ok, thanks for that
 

Users who are viewing this thread

Top Bottom