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

BUTTONS????

Status
Not open for further replies.

xpaccess

MIS
Jul 22, 2002
13
US
How can I get access 2002 to inport a excel file by clicking a button, and then have the data goto the right table and cells.
 
To import the spreadsheet by clicking on a button you can do something like this....

On the On_click event use the code

DoCmd.TransferSpreadsheet [transfertype][, spreadsheettype], tablename, filename[, hasfieldnames][, range]

[transfertype] .... you want to set to acImport

[Spreadsheettypes].... select the number corresponding to the spreadsheet you are importing from, from the following

0 acSpreadsheetTypeExcel3 (default)
6 acSpreadsheetTypeExcel4
5 acSpreadsheetTypeExcel5
5 acSpreadsheetTypeExcel7
8 acSpreadsheetTypeExcel97
2 acSpreadsheetTypeLotusWK1
3 acSpreadsheetTypeLotusWK3
7 acSpreadsheetTypeLotusWK4
4 acSpreadsheetTypeLotusWJ2 — Japanese version only

[tablename].... the table you want to import to

[filename].... the path and filename of the spreadsheet you want to import from

[hasfieldnames]..... Use True (–1) to use the first row of the spreadsheet as field names when importing or linking. Use False (0) to treat the first row of the spreadsheet as normal data. If you leave this argument blank, the default (False) is assumed.

[Range].... Optional field..... you may specify the field you want to import

eg.

DoCmd.TransferSpreadsheet acImport, 8, "tblName","C:\Location\tblName.xls", True, "A1:G12"

If you have a look in the help file under "TransferSpreadsheet Method" it explains this a lot more clearly.

Hope this is what you want.

Cheers

Neemi

 
I will give this a try to day and let you know how it worked. Thanks for the tip.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top