?
Solved

Creating a Linked Table (Linked to TEXT)

Posted on 1998-01-11
2
Medium Priority
?
359 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

Hire Technology Freelancers with Gigs

Work with freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely, and get projects done right.

Question has a verified solution.

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

There are many ways to remove duplicate entries in an SQL or Access database. Most make you temporarily insert an ID field, make a temp table and copy data back and forth, and/or are slow. Here is an easy way in VB6 using ADO to remove duplicate row…
If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
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 utilization of class modules. Class modules can be a powerful tool in Microsoft Access. They allow you to create self-contained objects that encapsulate functionality. They can easily hide the complexity of a process from…
Suggested Courses

650 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