473,554 Members | 2,530 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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 9134
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.c om...
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.c om...
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\BA R\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.c om...
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:\Docume nts and Settings\Me\Des ktop\Testing*.t xt")

DoCmd.TransferT ext 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\BA R\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:\Docume nts and Settings\Me\Des ktop\Testing*.t xt")

DoCmd.TransferT ext acImportDelim, "", "TestTable" , "C:\Documen ts and
Settings\Me\Des ktop\" & 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.c om...
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:\Docume nts and Settings\Me\Des ktop\Testing*.t xt")

DoCmd.TransferT ext 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\BA R\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_djsteel e@NOSPAM_canada .com> wrote:
DoCmd.Transfer Text acImportDelim, "", "TestTable" , "C:\Documen ts and
Settings\Me\De sktop\" & 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_djsteel e@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:\Docume nts and Settings\Me\Des ktop\Testing*.t xt")

DoCmd.TransferT ext acImportDelim, "", "TestTable" , "C:\Documen ts and
Settings\Me\De sktop\" & stFile, True, ""


Nov 13 '05 #10

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

Similar topics

2
1941
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 staging table with 3-key PK. When duplicates are attempting import, I receive a msgbox stating the number of records that violated the PK and asks if...
6
3015
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 newsgroup forum, so this fact was fixed. Since I have to transfer files from VMS( SAS ) to WIN (Access), I still keep using ACC97 as a simplest and...
4
9461
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 e.g. must field1, field2, filed3 etc correspond to col1, col2, col3 on the table? or can I state somewhere which columns in the text file...
3
545
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 http://www.developersdex.com *** Don't just participate in USENET...get rewarded for it!
3
4353
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 works like a champ everytime it's run. If I use VBA to execute a TransferText and specify the specfile, I get a Type Conversion Error on import and a...
3
12662
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 Access table in under 1 minute, using File>Get External Data>Import, then specifying .txt as the data source, selecting the text file, and walking...
3
9384
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
1403
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 after importing 6139 records each time on my side. After further research, there maybe a memory leak in TransferText. When the number of records exceeds...
0
2011
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 file below in WordPad and call the file "HeaderYES.txt" (the space between the two fields is actually a tab):- "Column1" "Column2" 1 ...
0
7539
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language...
0
7819
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. ...
0
8055
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that...
1
7581
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
1
5446
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes...
0
3589
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in...
0
3566
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
1149
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
858
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...

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.