473,418 Members | 2,640 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,418 software developers and data experts.

Automating a command button to do a Get External Data command

I'm trying to use a command button to the same thing as going to the
file menu and doing a Get External Data command to make the import
process easier for some end users. I'm using Access 2k, I have the
following code but I can't seem to get it to work properly.

Private Sub Command18_Click()
Dim strFileName As String
Dim strPath As String

strPath = "C:\ data" 'the location of the files
strFileName = "report.csv"

DoCmd.TransferText acImportDelim, "Data", strPath &
strFileName, "PC_Date", False
End Sub

Is there someone that can tell me what I'm missing or what I have
wrong.
Thanks

Dec 9 '05 #1
3 2491
Br
Bill wrote:
I'm trying to use a command button to the same thing as going to the
file menu and doing a Get External Data command to make the import
process easier for some end users. I'm using Access 2k, I have the
following code but I can't seem to get it to work properly.

Private Sub Command18_Click()
Dim strFileName As String
Dim strPath As String

strPath = "C:\ data" 'the location of the files
strFileName = "report.csv"

DoCmd.TransferText acImportDelim, "Data", strPath &
strFileName, "PC_Date", False
End Sub

Is there someone that can tell me what I'm missing or what I have
wrong.
Thanks
First, did you check the Access help? I've included a snippet from it
below.

It is hard to diagnose the problem when you don't tell us what happens
when you run the code? Nor do we get a clear indication of what "data"
and "PC_Date" are?

---------- From the Access Help

Syntax:

DoCmd.TransferText [transfertype][, specificationname], tablename,
filename[, hasfieldnames][, HTMLtablename][, codepage]

Remarks
You can leave an optional argument blank in the middle of the syntax,
but you must include the argument's comma. If you leave a trailing
argument blank, don't use a comma following the last argument you
specify.

----------
DoCmd.TransferText acImportDelim, "Data", strPath &
strFileName, "PC_Date", False


According to the syntax desscription your code reads:

Transfertype = acImportDelim (ok)
SpecificationName = "Data"
Tablename = strPath & strFileName
Filename = "PC_Date"
HasFieldNames = False

Don't forget to include commas for all the options even if you are
leaving them blank (except ones that are at the end of the line).

eg. No value given for specification, HTMLtablename, or Codepage

Docmd.TransferText acImportDelim, ,"tblMyTable", "c:\myfile.txt", False
--
regards,

Bradley

A Christian Response
http://www.pastornet.net.au/response
Dec 9 '05 #2
I have the command working now but because some of the headers have a
"." in the name its seeing the period as a delimiting character.
Because this is happening it's not finding the corresponding fields in
the table. Is there a way of telling it to only look for commas ","
to separate the data??

Dec 9 '05 #3
I was wrong. What is really happening is that the "." showing up as a
"#" and that is the reason that I can't get it to compleatly inport the
data. Any Ideas as to why that might be happening and how to fix the
problem??

Dec 9 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

0
by: Chanus | last post by:
I'm trying to automate a series of commands in ACCESS to import a data file in XML format. Normal procedure: -Start "MS Access" -Click "File->Get External Data->Import" -Choose the appropriate...
4
by: James Johnson | last post by:
Dear C#Dex, I am trying to automate a POST to a web page that clicks a button. I have been able to hit a target web page and run the web page. However, the button on the page does not click. ...
9
by: Neo Geshel | last post by:
I have strip-mined, strip-searched, and completely exhausted the Internet (up to the 30th page on Google, with 100 results per page!!), all without finding an answer to my question AS TO WHY IT...
1
by: chris_j_adams | last post by:
Hi, I'm trying to use Excel VBA ('97) to send details from an Excel sheet to a web page. I'm having some success but I've one issue that's proved difficult to find in the archives. There are...
7
by: support | last post by:
Hi, I am trying to change the text of a Command button using the Windows API Function SetWindowText, which I have declared as follows: <DllImport("User32")_ Public Function...
3
by: jlw16 | last post by:
Hello, I’m trying to use my vbs script to get a command line argument for a file which will need to be opened through QuickTestPro. Below are the commands I’m using: Dim qt_file 'As String ->...
4
by: attachmatey | last post by:
Greetings: I'm looking for some help in automating (what I thought would be) a simple procedure in Internet Explorer. I'm trying to put the following operation under a button click in an MS...
7
JodiPhillips
by: JodiPhillips | last post by:
Hi, My first post! I've basically taught myself Access and the little I know about VBA through reading these forums and a couple of books. I'm in the middle of a project at work - to put it...
2
by: iamdennis | last post by:
Hi all. I stuck here and need some help. I have created a combo box which contains a list of links to external PDF files. I also created a OPEN command button next to the combo box. I want to...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.