By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
424,506 Members | 2,311 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 424,506 IT Pros & Developers. It's quick & easy.

Linked Table Question

P: n/a
I've developed an app that allows the user to choose a text file to link to
using the TransferText method. It works fine but I want to mitigate for the
user choosing the wrong file. I thought I'd do this by testing the linked
file for the existance of a certain header (field) name but am not sure what
method/syntax to use.

Any suggestions (other than buy a book)?

Many thanks.

Keith.

Sep 19 '07 #1
Share this Question
Share on Google+
3 Replies


P: n/a
"Keith Wilby" <he**@there.comwrote in message
news:46**********@glkas0286.greenlnk.net...
I've developed an app that allows the user to choose a text file to link
to using the TransferText method. It works fine but I want to mitigate
for the user choosing the wrong file. I thought I'd do this by testing
the linked file for the existance of a certain header (field) name but am
not sure what method/syntax to use.
This is what I have so far:

DoCmd.TransferText acLinkDelim, , "csvWindchill", strFilePath, True 'Link to
the chosen file
Dim tdf As TableDef
Set tdf = db.CreateTableDef("csvWindchill")
tdf.SourceTableName = "csvWindchill"
If Not tdf.Fields("Progress Plan") Then ...

but the last line is obviously not right. I can trap the "item not found in
this collection" error but there must be a more elegant way to do this.

Thanks.
Keith.

Sep 19 '07 #2

P: n/a
On Wed, 19 Sep 2007 14:26:10 +0100, "Keith Wilby" <he**@there.com>
wrote:

I'm assuming you prompt the user for the file by popping up a
File/Open dialog. After it returns with a full path, before attaching
the file, I would use regular file i/o functions like Open, Line Input
etc to test the file.
Alternatively you can go ahead and attach any file, and then use
database queries and/or DAO code to test the data.

Here is one test of the attached table:
if currentdb.tabledefs("MyTextFileTable").Fields.Coun t <10 then
MsgBox "Aarrrccchhh, I was expecting 10 columns", vbCritical
end if

-Tom.

>I've developed an app that allows the user to choose a text file to link to
using the TransferText method. It works fine but I want to mitigate for the
user choosing the wrong file. I thought I'd do this by testing the linked
file for the existance of a certain header (field) name but am not sure what
method/syntax to use.

Any suggestions (other than buy a book)?

Many thanks.

Keith.
Sep 19 '07 #3

P: n/a
"Tom van Stiphout" <no*************@cox.netwrote in message
news:9q********************************@4ax.com...
On Wed, 19 Sep 2007 14:26:10 +0100, "Keith Wilby" <he**@there.com>
wrote:
Here is one test of the attached table:
if currentdb.tabledefs("MyTextFileTable").Fields.Coun t <10 then
MsgBox "Aarrrccchhh, I was expecting 10 columns", vbCritical
end if
Thanks Tom.

Sep 20 '07 #4

This discussion thread is closed

Replies have been disabled for this discussion.