473,387 Members | 1,603 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,387 software developers and data experts.

How can I transfer text file with strange name?

How can I transfer text with the following filename in Access 2002?:

somefilename.ccyymmdd (where "ccyymmdd" is the current date)

I would be able to do if the file name was: somefilename_ccyymmdd.txt

Thanks ahead of time.
Jul 27 '12 #1
7 2566
twinnyfo
3,653 Expert Mod 2GB
Can you change the file name extension so that it is a .txt file? If it is a text file, I don't think Access cares what the extension is, as long as it is in an appropriate format.

Is the filename required for anything, i.e., do you need to extract the date for any reason?
Jul 27 '12 #2
Thanks for replying. The file name extension cannot be changed. The date stamp is needed for archiving purposes. So I'm stuck with the strange and dynamic file name. I changed the extension to .txt and ran the transfer. MS Jet Engine is having a problem with the two periods in the file name. So I have 3 issues: (1) "capturing" the right date, (2) changing the file extension to something that is valid, (3) the two periods. Was thinking of changing the first "." to "_". Appreciate any advice.
Jul 27 '12 #3
twinnyfo
3,653 Expert Mod 2GB
For (1), to capture your date accurately, try this:

Expand|Select|Wrap|Line Numbers
  1. Option Compare Database
  2. Option Explicit
  3.  
  4. Private Sub GetDate(strFileName as String) as Date
  5. On Error GoTo EH
  6.     GetDate = CDate(Right(strFileName, 8))
  7.     Exit Sub
  8. EH:
  9.     MsgBox Err.Number & " " & Err.Description
  10.     Exit Sub
  11. End Sub
  12.  
You might have to play with the syntax you send into the CDate function, because it may or may not fully recognize the text of the file name as a date.

Concerning (2) and (3), how are the files saved in the fist place? If you change how they are saved initially, i.e. if, when the files are generated, they are saved as somefilename_ccyymmdd.txt, then you are golden. Otherwise, there are ways to rename files (or copy, paste under a new name and delete).

I think your first step of capturing the date is key, though.
Jul 27 '12 #4
twinnyfo
3,653 Expert Mod 2GB
Forgot to include this: The easiest way to rename files from VBA is this:

Expand|Select|Wrap|Line Numbers
  1.  
  2. Name OldName As NewName
  3.  
  4.  
Just be sure to include the entire directory path and full file name.
Jul 27 '12 #5
Thanks for your help. I will work with the code you sent and let you know how it goes.
Jul 27 '12 #6
It works. I forgot to mention that the Access job will run only at the beginning of the month, so I used the Date() function to get the current date, which will always be the file date. Did not know about the VBA Name statement. That did the trick.

I created a hidden form. "On Open" the form executes this code:

Private Sub Form_Open(Cancel As Integer)
Dim OldName, NewName
OldName = "\\servername\users$\myname\My Documents\testfolder\somefilename." & Format(Date(), "yyyymmdd"): NewName = "\\servername\users$\myname\My Documents\testfolder\somefilename_" & Format(Date(), "yyyymmdd") & ".txt" ' Define file names.
Name OldName As NewName ' Rename file.
End Sub

Then when I import the file ("TransferText"), this is the file name location:


="\\servername\users$\myname\My Documents\testfolder\somefilename_" & Format(Date(),"yyyymmdd") & ".txt"
Jul 27 '12 #7
Thanks again for your help!
Jul 27 '12 #8

Sign in to post your reply or Sign up for a free account.

Similar topics

12
by: alessia | last post by:
hi, I have a query that visualizes me, according to some criterions from me inserted, name , Surname , Address , phone ok.. Now, through a button, positioned in a Form, I have to only export...
6
by: jcrouse | last post by:
Here is a sniplet from a text file game name mapp description "Mappy (US) year 198 manufacturer "Namco history "\nMappy (c) 03/1983 Namco. \n\n- TRIVIA: \n\nLicensed to Bally Midway for US...
11
by: Nina | last post by:
I have a text file which stores user input. Later if user edited the input data from a input form. How can I update the input text file? If update the text file too often, would it cause...
14
by: Ilias Lazaridis | last post by:
within a python script, I like to create a collection which I fill with values from an external text-file (user editable). How is this accomplished the easiest way (if possible without the need...
1
by: Karan | last post by:
Directly transfer data from text file to oracle
2
by: Bhagya | last post by:
Hello All, Suppose the Contents of Text file is: Name Age Address AAA 5 #22 BBB 8 #99 -------------------------so on Can anybody tell me how to split this and insert this...
7
by: boss1 | last post by:
i have a text file like below: named "rez.text" and i wnt to transfer each column into oracle database which have the same column name as views here.Every time it will goto database atomatecally...
1
by: CAM123 | last post by:
I have added: <br><xsl:value-of select="Line" /></br> to my XSLT stylesheet to get a line per repeating block. When I view the output as XML it looks perfect - one line per block. However...
2
by: apank | last post by:
Using VBA, is there a way to transfer text a table or query and have the saved file name be some text followed by today's date (example"newfile.11.17.08.txt"). Also can that file then be winzipped...
8
by: jyaseen | last post by:
I used the follwing code to download the text file from my server location. my php file to read the following code name is contacts.php it is downloading the text file but , this text file...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
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?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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
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...

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.