Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

RunSQL action error for combining tables

Status
Not open for further replies.

chris9

Programmer
Feb 11, 2003
32
US
I am trying to merge two table together. The first one [Forms]![Form1]![Text0] is being created in a form by importing a text file and converting it to the table format I've already designed. However in one of the columns contain abbreviated values, so I created another table manually that just contains the abbreviations and values in two seperate columns. Here's my problem when I try Running the following SQL statment I get this error "A runSQL action requires an argument consisting of an SQL statemnt"

Can someone tell me what I need to change or another way to get my abbreviations spelled out in the imported table.
I've also tried creating a macro but it FROM clause is incorrect.

Thank you so much for helping!


DoCmd.RunSQL "SELECT [" & [Forms]![Form1]![Text0] & "].MakeAbbr, Makes.MakeName, [" & [Forms]![Form1]![Text0] & "].* FROM " & [Forms]![Form1]![Text0] & ", Makes WHERE ((([" & [Forms]![Form1]![Text0] & "].MakeAbbr) = [Makes].[MakeAbbr]))"
 
RunSQL is used to run Make-Table, Append or Update queries. Your SQL statement is a merely select clause, that's why you get the error message.

Just change it to:

Insert Into [NewTableName]([Field1], [Field2]) Select [WhateverField1], [WhateverField2] From [ImportedTable] Where YourCondition = True

HTH



[pipe]
Daniel Vlas
Systems Consultant
 
I'm still a little confused. I don't want to have another table. I just want to add the MakeName to my existing import table where my importedtable.MakeAbbr = Makes.MakeAbbr. I still need to have all the fields of the imported table.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top