?
Solved

Creating a Linked Table (Linked to TEXT)

Posted on 1998-01-11
2
Medium Priority
?
356 Views
Last Modified: 2008-08-07
I am trying to write code that creates a linked table to a text file.  I have already created the code that properly creates the MSysIMexSpecs, and MSYSIMEXColumns so that my import specs. can be used.  When I use the following code
sub tmp()
Dim tbldef As New TableDef
Dim dbs As Database
Set dbs = wks.OpenDatabase("r:\test.mdb")
tbldef.Attributes = dbAttachedTable
tbldef.Connect = "Text;DSN=ALLETA Link specification;FMT=Delimited;HDR=NO;IMEX=2;DATABASE=C:\Webpages\Database"
tbldef.Name = "ALLETA_LINK"
tbldef.SourceTableName = "ALLETA.TXT"
dbs.TableDefs.Append tbldef
end sub
   
I get an error on the attributes line. What is the proper way to do this.  I am trying to duplicate a database that I created in Access 97, in source code, so that the program can create it at install time.  
Thanks
0
Comment
Question by:redbaron082997
[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 Comments
 
LVL 6

Accepted Solution

by:
anthonyc earned 400 total points
ID: 1450393
This is what I would do:

public sub LinkTextTable
  dim db as database
  dim tblNew as tabledef

  set db = workspaces(0).opendatabase("r:\test.mdb")
.CreateTableDef([name[, attributes[, source[, connect]]]])
  set tblNew = db.createtabledef("ALLETA_LINK", dbAttachedTable, "ALLETA.TXT", "Text;DSN=ALLETA Link specification;FMT=Delimited;HDR=NO;IMEX=2;DATABASE=C:\Webpages\Database"
  db.tabledefs.append tblNew
end sub

Why is this different?  You are telling the actual database to create the new table.  This is how I do it.  I usually link dBase tables, but its all the same.
0
 
LVL 1

Author Comment

by:redbaron082997
ID: 1450394
Yes, but it doesn't find the Link specification.  It gives that error every time, even though I checked the tables and they are there correctly.  I assumed that for DSN=blah, that it would look in the MSYSIMEXSpecs, and Columns tables. That is what the problem has been. The syntax will work several different ways,but the error is always the same.  I could not find any documentation at all on the subject.  If I omit the DSN=blah then I get the attached table, and the field names and types are all automatic, and *wrong*.

0

Featured Post

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

When trying to find the cause of a problem in VBA or VB6 it's often valuable to know what procedures were executed prior to the error. You can use the Call Stack for that but it is often inadequate because it may show procedures you aren't intereste…
Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
Get people started with the process of using Access VBA to control Outlook using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Microsoft Outlook. Using automation, an Access applic…
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
Suggested Courses

770 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