Solved

Creating a Linked Table (Linked to TEXT)

Posted on 1998-01-11
2
349 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 200 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

Instantly Create Instructional Tutorials

Contextual Guidance at the moment of need helps your employees adopt to new software or processes instantly. Boost knowledge retention and employee engagement step-by-step with one easy solution.

Question has a verified solution.

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

Suggested Solutions

Introduction While answering a recent question about filtering a custom class collection, I realized that this could be accomplished with very little code by using the ScriptControl (SC) library.  This article will introduce you to the SC library a…
The debugging module of the VB 6 IDE can be accessed by way of the Debug menu item. That menu item can normally be found in the IDE's main menu line as shown in this picture.   There is also a companion Debug Toolbar that looks like the followin…
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…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

726 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