linked table empty 
Author Message
 linked table empty

I use the followong code to link a table to an external
Excel file but the linked table is empty although the
Excel file contains values? Am I missing anything?

Dim wsp As Workspace
    Dim dbsCurrent As Database
    Dim Tabulka As TableDef
    Dim ConnData As Connection

    Set dbsCurrent = CurrentDb
    Set Tabulka = dbsCurrent.CreateTableDef("Cenk_test")
    With Tabulka
    .Connect = "Excel
5.0;HDR=YES;IMEX=2;DATABASE=P:\Uzvěrka\Česky
Telecom\International\05_2002\CT_cenk_od_04_2002_test.xls"
    .SourceTableName = Ceny
    End With

    Set Sloupec = Tabulka.CreateField("Destinace", dbText)
    Tabulka.Fields.Append Sloupec

    Set Sloupec = Tabulka.CreateField("CENA (Kč/min)",
dbText)
    Tabulka.Fields.Append Sloupec

    dbsCurrent.TableDefs.Append Tabulka



Tue, 30 Nov 2004 19:12:49 GMT  
 linked table empty
I've always use DoCmd.TransferSpreadsheet to link to Excel files, so I'm not
sure of the details in doing it via DAO.  However, I think on this line

Quote:
>    .SourceTableName = Ceny

if "Ceny" is the name of the worksheet, it should be enclosed in quotes.  If
it's a variable, I don't see where it's defined, so you may be getting an
error there.

I don't know if you need to define the fields or not -- the example in the
help file under "Connect and SourceTableName Properties Example" doesn't do
that, but I'm unsure of the ramifications.

--
Dirk Goldgar, MS Access MVP
www.datagnostics.com

(please reply to the newsgroup)


I use the followong code to link a table to an external
Excel file but the linked table is empty although the
Excel file contains values? Am I missing anything?

Dim wsp As Workspace
    Dim dbsCurrent As Database
    Dim Tabulka As TableDef
    Dim ConnData As Connection

    Set dbsCurrent = CurrentDb
    Set Tabulka = dbsCurrent.CreateTableDef("Cenk_test")
    With Tabulka
    .Connect = "Excel
5.0;HDR=YES;IMEX=2;DATABASE=P:\Uzvěrka\Česky
Telecom\International\05_2002\CT_cenk_od_04_2002_test.xls"
    .SourceTableName = Ceny
    End With

    Set Sloupec = Tabulka.CreateField("Destinace", dbText)
    Tabulka.Fields.Append Sloupec

    Set Sloupec = Tabulka.CreateField("CENA (Kč/min)",
dbText)
    Tabulka.Fields.Append Sloupec

    dbsCurrent.TableDefs.Append Tabulka



Fri, 03 Dec 2004 01:22:30 GMT  
 
 [ 2 post ] 

 Relevant Pages 

1. Changing the linked table path without the linked table manager

2. Empty resultset when adding to empty table : error

3. Empty tables in a multi-tables query

4. Empty tables in a multi-tables query

5. linking all fields in linked table?

6. Linked tables - changing the link

7. Changing Linked Table link?

8. To link procedure and table in visual linking...

9. Linked Table VS Import Table

10. linking empty field

11. Make adp table behave like linked mdb table.

12. Linking tables vs. Opening tables directly

 

 
Powered by phpBB® Forum Software