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 Shaun E on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Copy Select Columns in table to a datasheet subform

Status
Not open for further replies.

lexi0088

Technical User
Sep 7, 2004
49
I have two tables- chargeback(header info) and chargebackdetail(detail line items). I am using a form (links to chargeback tbl) and a subform (links to chargebackdetails tbl) to enter in the info.

We can use the form in two ways... 1 to enter in all the infor manually and 2 enter in header info manually and then enter details (subform) using excel file. In the instance where we will use an excel file, I have a command button which takes the excel file and throws it into a temp table. However, I only need 4 columns from this table (out of the 20 columns from original spreadsheet) to be copied into my subform. This importtable can contain as little as 1 record and as many as 100 records.

I am just looking for some code that will copy select columns from a temp table into my datasheet subform. Please help me if you can
 
OK, I have figured out how to copy columns from one table to another using the following code

DoCmd.RunSQL "INSERT INTO [Chargeback Detail](Quantity,NDC,UnitCredit) SELECT qty,ndc_item,chargeback_amt FROM [ImportTable]"


However, I would like it to insert it into my subform (because of some calculations, etc in subform), sort of looking like this:

DoCmd.RunSQL "INSERT INTO Forms![Chargeback]![Chargeback Details](Quantity,NDC,UnitCredit) SELECT qty,ndc_item,chargeback_amt FROM [ImportTable]"

But I am geeting a Syntax Error in Insert Into Statement for this. Any suggestions would be very helpful
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top