Transferring spreadsheet from Excel to Access. problem with column name

bugsy

Registered User.
Local time
Today, 09:30
Joined
Oct 1, 2007
Messages
99
hi
i am transferring spreadsheet from Excel to Access table

Code:
pathbgc = Path & "\X.xls"
DoCmd.TransferSpreadsheet acImport, , "tableX", pathbgc, vbYes


pathbgc = Path & "\Y.xls"
DoCmd.TransferSpreadsheet acImport, , "tableY", pathbgc, vbYes

This works fine as long as column names in Excel do not have periods. (.)
Other then asking whoever is sending this not to put periods, is there painless way ignore that fact that excel has it, un just do it without it ?
 
You could ignore the fieldnames and after transfering the spreadsheet create your own.
By default the Fieldnames are Field1, Field2, ...
Using an Alter Table statement you can change the fieldnames and types.
 
You could ignore the fieldnames and after transfering the spreadsheet create your own.
By default the Fieldnames are Field1, Field2, ...
Using an Alter Table statement you can change the fieldnames and types.

Do I just change vbYES to vnNO ?
that diesn;t work. Gives me an error 'doesn't exist' (??)
Should i do a table with column names Fiels1, Filed2, etc, and import into that table ?

'X
pathbgc = Path & "\X.xls"
DoCmd.TransferSpreadsheet acImport, , "X", pathbgc, vbNo
 
Use False instead of vbNo and True instead of vbYes.
 
Use False instead of vbNo and True instead of vbYes.

Doesn't look like it changes anything...
The table has fileds now.Should I change the column names on the access table to F1, F2, F3, etc ?
that's only way it seems to be working :--/
i'd rather not
 
Could you post the excel file ? only a few lines.
 
Here's the first 2 lines from Excel files. (i can also do attachment)
Colun thats creating a problem is Issuer Deli. Oblig


Once I get rid of period in its name, problem disappears..


Refer # Broker Id Buy/Sell Protection Amt (M) Prod Issuer Deli. Oblig
2007709765 Rafferty Capital Markets SELL 5 CDS TOLL BROS 6.875% OF 11/12, ISIN: US88947EAA82
2007709768 Rafferty Capital Markets SELL 2 CDS KBH5 3/4 02/01/14 US48666KAH23
 
You can't use the Includes Header option for exports as setting it FALSE in code doesn't do a thing. What you could do is open the spreadsheet using the Excel COM Object Model, do a search on the headers and get rid of any specific characters.
 

Users who are viewing this thread

Back
Top Bottom