Linking Text File in DAO - does not work. 
Author Message
 Linking Text File in DAO - does not work.

There is exist function:

'************************************************
' Return True if link was created seccsessfully
'************************************************
Public Function AddLinkTableTXT(ByVal sLinkTName As String, ByVal
sSourceFName As String, ByVal sSpecification As String) As Boolean
' sLinkTName - Name of table in curent DB
' sSourceTName - real table name (from NameMDB)
' NameMDB - filename of DB where the sSourceTName is.
    Dim tDef As TableDef
    Dim dbc As Database

    Set dbc = CurrentDb
    On Error Resume Next
    dbc.TableDefs.Delete (sLinkTName)
    dbc.TableDefs.Refresh
    On Error GoTo ErrLink
    Set tDef = New TableDef
    tDef.name = sLinkTName
    tDef.Connect = "Text;DSN=" + sSpecification +
";FMT=Fixed;HDR=NO;IMEX=2;Database=" + GetPath(sSourceFName)
    tDef.SourceTableName = GetName(sSourceFName) + "." +
GetExt(sSourceFName)
    DoCmd.TransferText acImportFixed, sSpecification, sLinkTName,
sSourceFName, False
    dbc.TableDefs.Append tDef
    AddLinkTableTXT = True

    Exit Function

ErrLink:
    AddLinkTableTXT = False
    Exit Function
End Function
****************************************************************************
*******************************

Each time I'm getting False as a result because of error :
 3625
The text file specification 'Account_PP_Link_Specification' does not exist.
You can't import, export, or link using the specification.

BUT: Specification 'Account_PP_Link_Specification'  does exist
!!!!!!!!!!!!!!!
(I've checked it in system table).

And I can upload this ... file by command:
 'DoCmd.TransferText acImportFixed, sSpecification, sLinkTName,
sSourceFName, False'
which works just perfect! But I do not want to do this!

After link any text file  "by hand" everything is works! Text file links by
this function without any problem.

Any solutions? HELP !!!!!!!!!!!



Sat, 11 Oct 2003 01:58:00 GMT  
 Linking Text File in DAO - does not work.
Try to use
tDef.SourceTableName = GetName(sSourceFName) + "#" +
GetExt(sSourceFName)

Alex


Quote:
> There is exist function:

> '************************************************
> ' Return True if link was created seccsessfully
> '************************************************
> Public Function AddLinkTableTXT(ByVal sLinkTName As String, ByVal
> sSourceFName As String, ByVal sSpecification As String) As Boolean
> ' sLinkTName - Name of table in curent DB
> ' sSourceTName - real table name (from NameMDB)
> ' NameMDB - filename of DB where the sSourceTName is.
>     Dim tDef As TableDef
>     Dim dbc As Database

>     Set dbc = CurrentDb
>     On Error Resume Next
>     dbc.TableDefs.Delete (sLinkTName)
>     dbc.TableDefs.Refresh
>     On Error GoTo ErrLink
>     Set tDef = New TableDef
>     tDef.name = sLinkTName
>     tDef.Connect = "Text;DSN=" + sSpecification +
> ";FMT=Fixed;HDR=NO;IMEX=2;Database=" + GetPath(sSourceFName)
>     tDef.SourceTableName = GetName(sSourceFName) + "." +
> GetExt(sSourceFName)
>     DoCmd.TransferText acImportFixed, sSpecification, sLinkTName,
> sSourceFName, False
>     dbc.TableDefs.Append tDef
>     AddLinkTableTXT = True

>     Exit Function

> ErrLink:
>     AddLinkTableTXT = False
>     Exit Function
> End Function

****************************************************************************

- Show quoted text -

Quote:
> *******************************

> Each time I'm getting False as a result because of error :
>  3625
> The text file specification 'Account_PP_Link_Specification' does not
exist.
> You can't import, export, or link using the specification.

> BUT: Specification 'Account_PP_Link_Specification'  does exist
> !!!!!!!!!!!!!!!
> (I've checked it in system table).

> And I can upload this ... file by command:
>  'DoCmd.TransferText acImportFixed, sSpecification, sLinkTName,
> sSourceFName, False'
> which works just perfect! But I do not want to do this!

> After link any text file  "by hand" everything is works! Text file links
by
> this function without any problem.

> Any solutions? HELP !!!!!!!!!!!



Sat, 11 Oct 2003 03:35:22 GMT  
 Linking Text File in DAO - does not work.
Same thing.:

"The text file specification 'Account_PP_Link_Specification' does not
exist."

:(


Quote:
> Try to use
> tDef.SourceTableName = GetName(sSourceFName) + "#" +
> GetExt(sSourceFName)

> Alex



> > There is exist function:

> > '************************************************
> > ' Return True if link was created seccsessfully
> > '************************************************
> > Public Function AddLinkTableTXT(ByVal sLinkTName As String, ByVal
> > sSourceFName As String, ByVal sSpecification As String) As Boolean
> > ' sLinkTName - Name of table in curent DB
> > ' sSourceTName - real table name (from NameMDB)
> > ' NameMDB - filename of DB where the sSourceTName is.
> >     Dim tDef As TableDef
> >     Dim dbc As Database

> >     Set dbc = CurrentDb
> >     On Error Resume Next
> >     dbc.TableDefs.Delete (sLinkTName)
> >     dbc.TableDefs.Refresh
> >     On Error GoTo ErrLink
> >     Set tDef = New TableDef
> >     tDef.name = sLinkTName
> >     tDef.Connect = "Text;DSN=" + sSpecification +
> > ";FMT=Fixed;HDR=NO;IMEX=2;Database=" + GetPath(sSourceFName)
> >     tDef.SourceTableName = GetName(sSourceFName) + "." +
> > GetExt(sSourceFName)
> >     DoCmd.TransferText acImportFixed, sSpecification, sLinkTName,
> > sSourceFName, False
> >     dbc.TableDefs.Append tDef
> >     AddLinkTableTXT = True

> >     Exit Function

> > ErrLink:
> >     AddLinkTableTXT = False
> >     Exit Function
> > End Function

****************************************************************************

- Show quoted text -

Quote:
> > *******************************

> > Each time I'm getting False as a result because of error :
> >  3625
> > The text file specification 'Account_PP_Link_Specification' does not
> exist.
> > You can't import, export, or link using the specification.

> > BUT: Specification 'Account_PP_Link_Specification'  does exist
> > !!!!!!!!!!!!!!!
> > (I've checked it in system table).

> > And I can upload this ... file by command:
> >  'DoCmd.TransferText acImportFixed, sSpecification, sLinkTName,
> > sSourceFName, False'
> > which works just perfect! But I do not want to do this!

> > After link any text file  "by hand" everything is works! Text file links
> by
> > this function without any problem.

> > Any solutions? HELP !!!!!!!!!!!



Sat, 11 Oct 2003 04:15:14 GMT  
 Linking Text File in DAO - does not work.
Andre

Try renaming the specification to something shorter with the underscore
characters.

Phillip Carter


Quote:
> There is exist function:

> '************************************************
> ' Return True if link was created seccsessfully
> '************************************************
> Public Function AddLinkTableTXT(ByVal sLinkTName As String, ByVal
> sSourceFName As String, ByVal sSpecification As String) As Boolean
> ' sLinkTName - Name of table in curent DB
> ' sSourceTName - real table name (from NameMDB)
> ' NameMDB - filename of DB where the sSourceTName is.
>     Dim tDef As TableDef
>     Dim dbc As Database

>     Set dbc = CurrentDb
>     On Error Resume Next
>     dbc.TableDefs.Delete (sLinkTName)
>     dbc.TableDefs.Refresh
>     On Error GoTo ErrLink
>     Set tDef = New TableDef
>     tDef.name = sLinkTName
>     tDef.Connect = "Text;DSN=" + sSpecification +
> ";FMT=Fixed;HDR=NO;IMEX=2;Database=" + GetPath(sSourceFName)
>     tDef.SourceTableName = GetName(sSourceFName) + "." +
> GetExt(sSourceFName)
>     DoCmd.TransferText acImportFixed, sSpecification, sLinkTName,
> sSourceFName, False
>     dbc.TableDefs.Append tDef
>     AddLinkTableTXT = True

>     Exit Function

> ErrLink:
>     AddLinkTableTXT = False
>     Exit Function
> End Function

****************************************************************************

- Show quoted text -

Quote:
> *******************************

> Each time I'm getting False as a result because of error :
>  3625
> The text file specification 'Account_PP_Link_Specification' does not
exist.
> You can't import, export, or link using the specification.

> BUT: Specification 'Account_PP_Link_Specification'  does exist
> !!!!!!!!!!!!!!!
> (I've checked it in system table).

> And I can upload this ... file by command:
>  'DoCmd.TransferText acImportFixed, sSpecification, sLinkTName,
> sSourceFName, False'
> which works just perfect! But I do not want to do this!

> After link any text file  "by hand" everything is works! Text file links
by
> this function without any problem.

> Any solutions? HELP !!!!!!!!!!!



Sat, 11 Oct 2003 18:25:41 GMT  
 Linking Text File in DAO - does not work.
I also had problems with link specs (although not this one) and turned to
opening the CSV as a recordset instead. May be more flexible, depending what
you're doing with the data.

You can execute the select statement in code to open a recordset or save it
as a query;

"SELECT * FROM [Text;FMT=Delimited;HDR=Yes;DATABASE=" & Path(strFilePath) &
";].[" & strCSVFileName & "#csv];"

The Schema.ini file controls the sort of things the link specifications do
with TransferDatabase but has the benefit of being an external text file you
can edit.

Search the MS KB for Schema.ini for details.

HTH, Mark P


Quote:
> There is exist function:

> '************************************************
> ' Return True if link was created seccsessfully
> '************************************************
> Public Function AddLinkTableTXT(ByVal sLinkTName As String, ByVal
> sSourceFName As String, ByVal sSpecification As String) As Boolean
> ' sLinkTName - Name of table in curent DB
> ' sSourceTName - real table name (from NameMDB)
> ' NameMDB - filename of DB where the sSourceTName is.
>     Dim tDef As TableDef
>     Dim dbc As Database

>     Set dbc = CurrentDb
>     On Error Resume Next
>     dbc.TableDefs.Delete (sLinkTName)
>     dbc.TableDefs.Refresh
>     On Error GoTo ErrLink
>     Set tDef = New TableDef
>     tDef.name = sLinkTName
>     tDef.Connect = "Text;DSN=" + sSpecification +
> ";FMT=Fixed;HDR=NO;IMEX=2;Database=" + GetPath(sSourceFName)
>     tDef.SourceTableName = GetName(sSourceFName) + "." +
> GetExt(sSourceFName)
>     DoCmd.TransferText acImportFixed, sSpecification, sLinkTName,
> sSourceFName, False
>     dbc.TableDefs.Append tDef
>     AddLinkTableTXT = True

>     Exit Function

> ErrLink:
>     AddLinkTableTXT = False
>     Exit Function
> End Function

****************************************************************************

- Show quoted text -

Quote:
> *******************************

> Each time I'm getting False as a result because of error :
>  3625
> The text file specification 'Account_PP_Link_Specification' does not
exist.
> You can't import, export, or link using the specification.

> BUT: Specification 'Account_PP_Link_Specification'  does exist
> !!!!!!!!!!!!!!!
> (I've checked it in system table).

> And I can upload this ... file by command:
>  'DoCmd.TransferText acImportFixed, sSpecification, sLinkTName,
> sSourceFName, False'
> which works just perfect! But I do not want to do this!

> After link any text file  "by hand" everything is works! Text file links
by
> this function without any problem.

> Any solutions? HELP !!!!!!!!!!!



Fri, 17 Oct 2003 22:00:53 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. Linking a text file to an mdb through DAO

2. Help: updating text file-Updating Data in a linked table not supported by this ISAM

3. DAO Blob Adding/Extracting (audio files, text files, image files, program files)

4. Herlp: LIKE in SQL doe not work anymore

5. VB4 text box Align text property not working

6. VB4 text box Align text property not working

7. Refresh/Requery don't seem to work while doing file I/O

8. DAO not working in Access 2000

9. DAO works on small tbls but not on large

10. ADO control works with Acess 2000 but DAO Control does not

11. DBLISTBOX will not work with a DAO recordset?

12. SQL syntax worked for DAO, not RDO?

 

 
Powered by phpBB® Forum Software