Solved

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

Posted on 2013-12-04
4
345 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:murbro
  • 2
  • 2
4 Comments
 
LVL 119

Expert Comment

by:Rey Obrero
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:murbro
ID: 39696682
Thanks. Does that mean that I don't have to use import specifications.

Thanks
0
 
LVL 119

Accepted Solution

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

Author Comment

by:murbro
ID: 39697445
Great. Thanks very much
0

Featured Post

Enterprise Mobility and BYOD For Dummies

Like “For Dummies” books, you can read this in whatever order you choose and learn about mobility and BYOD; and how to put a competitive mobile infrastructure in place. Developed for SMBs and large enterprises alike, you will find helpful use cases, planning, and implementation.

Question has a verified solution.

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

In a multiple monitor setup, if you don't want to use AutoCenter to position your popup forms, you have a problem: where will they appear?  Sometimes you may have an additional problem: where the devil did they go?  If you last had a popup form open…
I see at least one EE question a week that pertains to using temporary tables in MS Access.  But surprisingly, I was unable to find a single article devoted solely to this topic. I don’t intend to describe all of the uses of temporary tables in t…
In Microsoft Access, learn how to use Dlookup and other domain aggregate functions and one method of specifying a string value within a string. Specify the first argument, which is the expression to be returned: Specify the second argument, which …
Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

911 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

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now