473,412 Members | 2,075 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,412 software developers and data experts.

Can I use wildcards in TransferText import?

I need to import a text file pretty much daily. I download the file
and change the name to a standard name and then run the code to import
the file into a table in my database. The problem is that the file
starts with a standard name but adds the date and some other stuff to
the end of the file name. Is there a way I could use a wildcard like
"*" so I wouldn't have to change the name?

Thanks for any help
Nov 13 '05 #1
11 9114
No, you cannot -- when the filesystem opens a file it needs a legal name.
But you can write code to get the name that uses wildcards via the Dir()
function, and then use the name you get....
--
MichKa [MS]
NLS Collation/Locale/Keyboard Development
Globalization Infrastructure and Font Technologies

This posting is provided "AS IS" with
no warranties, and confers no rights.
"Shyguy" <sh****@aol.com> wrote in message
news:o4********************************@4ax.com...
I need to import a text file pretty much daily. I download the file
and change the name to a standard name and then run the code to import
the file into a table in my database. The problem is that the file
starts with a standard name but adds the date and some other stuff to
the end of the file name. Is there a way I could use a wildcard like
"*" so I wouldn't have to change the name?

Thanks for any help

Nov 13 '05 #2
I'm not sure I follow. The original filename doesn't use wildcards.
it just has different endings. Are you saying I can write code to
change the file name into a specific name?

On Thu, 10 Jun 2004 20:10:42 -0700, "Michael \(michka\) Kaplan [MS]"
<mi*****@online.microsoft.com> wrote:
No, you cannot -- when the filesystem opens a file it needs a legal name.
But you can write code to get the name that uses wildcards via the Dir()
function, and then use the name you get....


Nov 13 '05 #3
You can write code to

(1) detect the filename (using wildcards)
(2) use that detected filename in your call to TransferText
--
MichKa [MS]
NLS Collation/Locale/Keyboard Development
Globalization Infrastructure and Font Technologies

This posting is provided "AS IS" with
no warranties, and confers no rights.
"Shyguy" <sh****@aol.com> wrote in message
news:46********************************@4ax.com...
I'm not sure I follow. The original filename doesn't use wildcards.
it just has different endings. Are you saying I can write code to
change the file name into a specific name?

On Thu, 10 Jun 2004 20:10:42 -0700, "Michael \(michka\) Kaplan [MS]"
<mi*****@online.microsoft.com> wrote:
No, you cannot -- when the filesystem opens a file it needs a legal name.
But you can write code to get the name that uses wildcards via the Dir()
function, and then use the name you get....

Nov 13 '05 #4
Thanks for your reply and patience. Being pretty much a beginner at
this, I really have no clue as the where to start this. Could you
direct me to sample code, or a starting place to search?

Thanks again
On Fri, 11 Jun 2004 10:00:18 -0700, "Michael \(michka\) Kaplan [MS]"
<mi*****@online.microsoft.com> wrote:
You can write code to

(1) detect the filename (using wildcards)
(2) use that detected filename in your call to TransferText


Nov 13 '05 #5
As I said, the Dir() function is your friend. You can say (in VBA):

Dim stFile As String

stFile = Dir$("C:\FOO\BAR\FILE??.TXT")

and stFile will contain the first file in C:\FOO\BAR\ that matches the
pattern given.

From there you can call the TransferText method, passing stFile in as the
filename. For more info, look in the online help on the Dir$ function and
the TransferText method.
--
MichKa [MS]
NLS Collation/Locale/Keyboard Development
Globalization Infrastructure and Font Technologies

This posting is provided "AS IS" with
no warranties, and confers no rights.
"Shyguy" <sh****@aol.com> wrote in message
news:r3********************************@4ax.com...
Thanks for your reply and patience. Being pretty much a beginner at
this, I really have no clue as the where to start this. Could you
direct me to sample code, or a starting place to search?

Thanks again
On Fri, 11 Jun 2004 10:00:18 -0700, "Michael \(michka\) Kaplan [MS]"
<mi*****@online.microsoft.com> wrote:
You can write code to

(1) detect the filename (using wildcards)
(2) use that detected filename in your call to TransferText

Nov 13 '05 #6
Thank you so much for all the help. Unfortunately I still can't get
it to work. These are the two main lines of code.

stFile = Dir$("C:\Documents and Settings\Me\Desktop\Testing*.txt")

DoCmd.TransferText acImportDelim, "", "TestTable", stFile, True, ""

If I substitute stFile with the actual name of the file everything
works fine.

When I run it with the stFile, I get an error message saying that it
can't find the file, but it shows the correct file name in the error
message.
On Fri, 11 Jun 2004 21:57:14 -0700, "Michael \(michka\) Kaplan [MS]"
<mi*****@online.microsoft.com> wrote:
Dim stFile As String

stFile = Dir$("C:\FOO\BAR\FILE??.TXT")


Nov 13 '05 #7
All the Dir function returns is the name of the file without its folder. You
need to add the folder yourself.

stFile = Dir$("C:\Documents and Settings\Me\Desktop\Testing*.txt")

DoCmd.TransferText acImportDelim, "", "TestTable", "C:\Documents and
Settings\Me\Desktop\" & stFile, True, ""
--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)
"Shyguy" <sh****@aol.com> wrote in message
news:i3********************************@4ax.com...
Thank you so much for all the help. Unfortunately I still can't get
it to work. These are the two main lines of code.

stFile = Dir$("C:\Documents and Settings\Me\Desktop\Testing*.txt")

DoCmd.TransferText acImportDelim, "", "TestTable", stFile, True, ""

If I substitute stFile with the actual name of the file everything
works fine.

When I run it with the stFile, I get an error message saying that it
can't find the file, but it shows the correct file name in the error
message.
On Fri, 11 Jun 2004 21:57:14 -0700, "Michael \(michka\) Kaplan [MS]"
<mi*****@online.microsoft.com> wrote:
Dim stFile As String

stFile = Dir$("C:\FOO\BAR\FILE??.TXT")

Nov 13 '05 #8
Thank you, thank you, thank you. I thought that since the Dir$ was =
to the directory and file name that stFile would be = to the same.
Obviously I don't understand Dir$. ;-(

Although I do understand it a little better now.

Thanks again.

On Sat, 12 Jun 2004 11:53:25 GMT, "Douglas J. Steele"
<NOSPAM_djsteele@NOSPAM_canada.com> wrote:
DoCmd.TransferText acImportDelim, "", "TestTable", "C:\Documents and
Settings\Me\Desktop\" & stFile, True, ""


Nov 13 '05 #9
I ran into a slight snag. The files come in with 2 periods in
different places within the filename. Is there a way to remove the
periods with code?

On Sat, 12 Jun 2004 11:53:25 GMT, "Douglas J. Steele"
<NOSPAM_djsteele@NOSPAM_canada.com> wrote:
All the Dir function returns is the name of the file without its folder. You
need to add the folder yourself.

stFile = Dir$("C:\Documents and Settings\Me\Desktop\Testing*.txt")

DoCmd.TransferText acImportDelim, "", "TestTable", "C:\Documents and
Settings\Me\Desktop\" & stFile, True, ""


Nov 13 '05 #10
Even if the filename has periods in it, don't you need to keep it correct so
that you can refer to the file properly? If you remove the periods, how will
you be able to transfer the file name?

Or are you saying that you want to rename the files? If so, the Name
statement lets you.

Name "C:\Documents and Settings\Me\Desktop\" & stFile As _
Replace("C:\Documents and Settings\Me\Desktop\" & stFile, ".", "")

will remove the periods, while

Name "C:\Documents and Settings\Me\Desktop\" & stFile As _
Replace("C:\Documents and Settings\Me\Desktop\" & stFile, ".", "_")

will replace the periods with underscores

--
Doug Steele, Microsoft Access MVP
http://I.Am/DougSteele
(no e-mails, please!)
"Shyguy" <sh****@aol.com> wrote in message
news:bb********************************@4ax.com...
I ran into a slight snag. The files come in with 2 periods in
different places within the filename. Is there a way to remove the
periods with code?

On Sat, 12 Jun 2004 11:53:25 GMT, "Douglas J. Steele"
<NOSPAM_djsteele@NOSPAM_canada.com> wrote:
All the Dir function returns is the name of the file without its folder. Youneed to add the folder yourself.

stFile = Dir$("C:\Documents and Settings\Me\Desktop\Testing*.txt")

DoCmd.TransferText acImportDelim, "", "TestTable", "C:\Documents and
Settings\Me\Desktop\" & stFile, True, ""

Nov 13 '05 #11
Thank you again for all your help. I'm sorry I wasn't as clear as I
should have been. I was asking how to change the filename to have no
periods. I tried looking up the Name Statement in help, but couldn't
find anything. After adding your code the filename had no '.' s at
all, including the one between the name and "txt" so it wouldn't
import. I played around with it a bit and made it work. Probably not
the right way but it does work. I'm just thankful I don't do this for
a living. :-)

Thanks again for your help. Not just in this instance but in the past
as well.

On Sun, 13 Jun 2004 18:46:58 GMT, "Douglas J. Steele"
<NOSPAM_djsteele@NOSPAM_canada.com> wrote:
Even if the filename has periods in it, don't you need to keep it correct so
that you can refer to the file properly? If you remove the periods, how will
you be able to transfer the file name?

Or are you saying that you want to rename the files? If so, the Name
statement lets you.

Name "C:\Documents and Settings\Me\Desktop\" & stFile As _
Replace("C:\Documents and Settings\Me\Desktop\" & stFile, ".", "")

will remove the periods, while

Name "C:\Documents and Settings\Me\Desktop\" & stFile As _
Replace("C:\Documents and Settings\Me\Desktop\" & stFile, ".", "_")

will replace the periods with underscores


Nov 13 '05 #12

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

2
by: ms | last post by:
In Access 2000, I am using... 'Import Raw text to stageBMIDLog table. DoCmd.TransferText acImportFixed, "BMIDLog Link Specification", "stageBMIDLog", file ....to import raw records into a...
6
by: Vladislav Moltchanov | last post by:
I have discovered a couple of years ago, that import with DoCMD.TransferText for CSV text file doesn’t work in Acc2000, while it works perfectly in ACC97. which has been discussed on this...
4
by: khutch | last post by:
Not that up on MS Access. I understand that the TransferText command can be used to import csv files into a database. Question: Does the text file have to mirror the alignment of the table columns...
3
by: Jack Doman | last post by:
Does anyone know how I can use Access XP's TransferText method to import a tab delimited text file? It works fine for comma delimited files. *** Sent via Developersdex...
3
by: Typehigh | last post by:
I am a pretty saavy user, but I am having a real problem with the DoCmd.TransferText operation. I manually used the File>Get External Data> Import routine to set up an import specification. It...
3
by: holdemfoldem | last post by:
Hi. I'm new to this board and have a few questions about using the method referred to in the topic of this message. I have manually transferred over 1/2 million records from a text file into my...
3
by: Oliver Gabriel | last post by:
Hi, i want to export a table for later import, using vba. That´s my code: export: filename = "C:\HVOtabelle.txt"
0
by: matchine | last post by:
This is a recommendation based on my research on an issue with the transfer text functionality. The comments below were from a tech I approched for help. "The transfer text process blocked...
0
by: Sean Howard | last post by:
I have a strange problem linking tab delimited text files in Access 2000 (I am running Windows XP), please try this and let me know if I am going mad. Step 1. Create the tab-delimited text...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.