?
Solved

VB.net Excel Add-in manipulating text files via Access

Posted on 2013-12-04
4
Medium Priority
?
359 Views
Last Modified: 2013-12-04
Hi

I am using the following VB.net code to link an Access table to a text file
so that I can run a query on the data. I want to be able to automatically
do this with different text files coming from different database sources.
Is this technique reliable?

  Dim appAccess As New Microsoft.Office.Interop.Access.Application
        appAccess.OpenCurrentDatabase("C:\Users\murbro\Documents\Database1.accdb")
        appAccess.Visible = True

        'Link to a csv file so that it acts as a table in Access
        appAccess.DoCmd.TransferText(TransferType:=Microsoft.Office.Interop.Access.AcTextTransferType.acLinkDelim, TableName:="tblImport", _
    FileName:="C:\Users\murbro\Documents\MyData.txt", HasFieldNames:=True)
0
Comment
Question by:Murray Brown
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
  • 2
4 Comments
 
LVL 120

Expert Comment

by:Rey Obrero (Capricorn1)
ID: 39696662
yes, just change this part

 FileName:="C:\Users\murbro\Documents\MyData.txt"

to connect to the other text file.

if you will use the same table "TableName:="tblImport""

make sure to delete the table before linking
0
 

Author Comment

by:Murray Brown
ID: 39696682
Thanks. Does that mean that I don't have to use import specifications.

Thanks
0
 
LVL 120

Accepted Solution

by:
Rey Obrero (Capricorn1) earned 2000 total points
ID: 39696792
No, Import Spec is for Importing not for Linking files.
0
 

Author Comment

by:Murray Brown
ID: 39697445
Great. Thanks very much
0

Featured Post

Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

In Part II of this series, I will discuss how to identify all open instances of Excel and enumerate the workbooks, spreadsheets, and named ranges within each of those instances.
This article shows how to get a list of available printers for display in a drop-down list, and then to use the selected printer to print an Access report or a Word document filled with Access data, using different syntax as needed for working with …
In Microsoft Access, learn different ways of passing a string value within a string argument. Also learn what a “Type Mis-match” error is about.
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…
Suggested Courses
Course of the Month11 days, 20 hours left to enroll

752 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question