ACCESS - Macro using TransferSpreadsheet

fz1syc

New Member
Joined
Aug 4, 2004
Messages
8
I have a form with a text box. In the text box I want customers to key a file name which includes the entire path. Using a command button, a macro will execute a TransferSpreadsheet. How do I tell the macro what data to pick up from the form?

Thanks for your help!
 

Excel Facts

Select a hidden cell
Somehide hide payroll data in column G? Press F5. Type G1. Enter. Look in formula bar while you arrow down through G.
You will need to do this in code rather than a macro.

from help, the format is :-
DoCmd.TransferSpreadsheet [transfertype][, spreadsheettype], tablename, filename[, hasfieldnames][, range]

Giving this as an Example :-
DoCmd.TransferSpreadsheet acImport, 3, "Employees", "C:\Lotus\Newemps.wk3", True, "A1:G12"

To make this work using the file name from a field called txtPath you would use :-

DoCmd.TransferSpreadsheet acImport, 3, "Employees", Me![txtPath], True, "A1:G12"


HTH

Peter
 
Upvote 0

Forum statistics

Threads
1,221,813
Messages
6,162,126
Members
451,743
Latest member
matt3388

We've detected that you are using an adblocker.

We have a great community of people providing Excel help here, but the hosting costs are enormous. You can help keep this site running by allowing ads on MrExcel.com.
Allow Ads at MrExcel

Which adblocker are you using?

Disable AdBlock

Follow these easy steps to disable AdBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the icon in the browser’s toolbar.
2)Click on the "Pause on this site" option.
Go back

Disable AdBlock Plus

Follow these easy steps to disable AdBlock Plus

1)Click on the icon in the browser’s toolbar.
2)Click on the toggle to disable it for "mrexcel.com".
Go back

Disable uBlock Origin

Follow these easy steps to disable uBlock Origin

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back

Disable uBlock

Follow these easy steps to disable uBlock

1)Click on the icon in the browser’s toolbar.
2)Click on the "Power" button.
3)Click on the "Refresh" button.
Go back
Back
Top