Programming Forums

Programming Forums (http://www.programmingforums.org/forumindex.php)
-   Visual Basic (http://www.programmingforums.org/forum18.html)
-   -   Access (http://www.programmingforums.org/showthread.php?t=14199)

u2cannv Oct 20th, 2007 12:27 PM

Access
 
Ive created a macro that should import/export a file based of certain criteria's: filename and filedate.
\\c\desktop\"johndoe" & Right("0" & Month(Date()), 2) & Right("0" & Day(Date()), 2) & Right(Year(Date()), 2) & ".txt
when i insert the code into the field "filename" using the action "TransferText" i receive the following errors: microsoft access cant parse the expression or filename has to end in .txt or .csv. can someone inform me as to whats wrong with the code?

Thanks

OpenLoop Oct 20th, 2007 2:06 PM

Re: Access
 
Lets switch to VBA Macros again because they're easier to debug. I pulled your code from your previous post:
:

Option Compare Database
Option Explicit

Public Sub Import()
Dim Joe As Date
Dim John As String
Dim result As String
Jon = Format(Date, "MMDDYY")

DoCmd.TransferText acImportDelim, "3RPV EXPORT", "Johndoe*.txt", "johndoe*.TXT"

The first step would be to correctly figure out the file name. Where is the data file located? For now, I'll assume it at "C:\desktop\johndoeMMDDYY.txt" where MMDDYY is the current date:
:

fileDt = Format(Date, "MMDDYY")
fileNm = "C:\Desktop\" & "johndoe" & fileDt & ".txt"
MsgBox (fileNm)

I put the MsgBox to display the final filename. If this is the correct file name, use it in TransferText and this should work.


All times are GMT -5. The time now is 3:18 AM.

Powered by vBulletin® Version 3.7.0, Copyright ©2000 - 2008, Jelsoft Enterprises Ltd.
Copyright ©2007 DaniWeb® LLC