This is my code and works fine for csv but I am exporting to a folder that is sending to a zebra printer that must be in txt format. Thanks for any help, I have been racking my brains to no avail. This works: Sub transfercsv() DoCmd.TransferText acExportDelim, , "“TblLabel01"”, ““V:Dealer KittingTag Print FileTags Print File.csv””, False End Sub This gives me an error: Runtime Error 3051 Sub transfercsv() DoCmd.TransferText acExportDelim, , "“TblLabel01"”, ““V:Dealer KittingTag Print FileTags Print File.csv””, False End Sub
If they are scanning the folder to see if any new files exist, remember to create your new file with the READ WRITE LOCK attribute
That way any other application can not open it to read, write or use it until you are done and the file CLOSED.
That might help, it may be that the other application is opening the file before you have actually saved yours.
What if you export the txt file to a temp location and when it is done you move the file to V:Dealer KittingTag Print File.
I’m guessing the process run from the server is opening your file before the export process is done hence the error.
Wanderlei
Em 20/02/2017 11:08, JuniorIT escreveu:
Hi Chip,
This is what I have figured out so far.
The point of this area in the database is to print tags from the access
database. IT wanted me to export the table to be printed to a particular
folder (V:Dealer KittingTag Print File) and they put some code so that
anytime a txt file is put in the folder it automatically sends the file to
a zebra printer.
I have found I can export my table to any other location on the drive
(except this one) in txt format.
I can also export my table to V:Dealer KittingTag Print Filein .csv
format but then it will not print.
If I try to export in txt format to (V:Dealer KittingTag Print File) I
get the Runtime Error 3051.
There is no conflict with anything else printing at the time I export the
file.
Has anyone ever tackled this type issue?
This is my code and works fine for csv but I am exporting to a folder that
is sending to a zebra printer that must be in txt format. Thanks for any
help, I have been racking my brains to no avail.
This works:
Sub transfercsv()
DoCmd.TransferText acExportDelim, , “TblLabel01”, “V:Dealer KittingTag
Print FileTags Print File.csv”, False
End Sub
This gives me an error: Runtime Error 3051
Sub transfercsv()
DoCmd.TransferText acExportDelim, , “TblLabel01”, “V:Dealer KittingTag
Print FileTags Print File.txt”, False
End Sub
OK. Based on what you’ve just said, it probably isn’t your app that’s at fault. It sounds like the IT department (Work-prevention-unit) have a ‘file watcher’ installed that will look for your .TXT file. The reason why it doesn’t fall over with the .CSV file, is because the watcher is probably configured to look only for .TXT files.
You may have to export it to that folder as one file name, maybe export.tmp, and then rename the file to the .TXT. Alternatively, stick some error catching around the export to try again.
Martin
Ok, I think your side code is ok.
Are any processes to confirm that the file was saved correctly on the server instigated by your process? If so, because it is reading the file after saving for confirmation of validity, the printer could have grabbed it before the validation started. Long shot, as I don’t know how the printer server is set up. Is there a delay before printing, or is it “instantanious” when it arrives?
My next check is not what you’ve done, but how they are selecting and working on the files to be printed.
I’m thinking that comma seperated files are different from text files because of the suffix, and the content layout.
Some text files are more rigid than .csv. Are they converting the file into a .prn file if so how?
What processes, if any, are they carrying out on the file? I’m thinking that the .csv file may be converted in some way to be a fixed column type because they want it to be in columnar report format. (.csv isn’t) Just a thought.
Not read into all of this, but I do know that sometimes when generating CSV files - depending on the export application, it will automatically add embedded chars such as CHR$(9) - you cant visual see it in the file, but its there.
Txt files of course wouldn’t have those - have you checked the ASCII values for the output files ?
I have been frustrated by various issues exporting .csv, .txt. and .prn files. Most of the time it’s because the file is still open in another application, editor, or Excel. Have you tried these ideas:
If you have opened the file in Excel at ANY time, and Excel is still active (even if the file has been closed!) it will sometimes kick an error (as though the file was still open). If this is the case, try closing Excel as well before running the Access routine.
Probably seems overly-simply, but couldn’t you simply export the .csv file to a temporary directory, rename it with a .txt extension, and then transfer it to the “V” directory where it will be picked up by the auto-printing script? I didn’t see anything in the message thread to suggest that you tried the export-rename approach.
Hope this helps!
Sent from Mail for Windows 10
Hi Martin,
V is a network drive, I would think that if I did not have permission to
write on it I would not be able to export the .csv file to the drive which
I can.
It is only when I change the extension to .txt that it gives me this
error.
Thanks!
Diane
Hi Chip,
This is what I have figured out so far.
The point of this area in the database is to print tags from the access
database. IT wanted me to export the table to be printed to a particular
folder (V:Dealer KittingTag Print File) and they put some code so that
anytime a txt file is put in the folder it automatically sends the file to
a zebra printer.
I have found I can export my table to any other location on the drive
(except this one) in txt format.
I can also export my table to V:Dealer KittingTag Print Filein .csv
format but then it will not print.
If I try to export in txt format to (V:Dealer KittingTag Print File) I
get the Runtime Error 3051.
There is no conflict with anything else printing at the time I export the
file.
Has anyone ever tackled this type issue?
This is my code and works fine for csv but I am exporting to a folder that
is sending to a zebra printer that must be in txt format. Thanks for any
help, I have been racking my brains to no avail.
This works:
Sub transfercsv()
DoCmd.TransferText acExportDelim, , “TblLabel01”, “V:Dealer KittingTag
Print FileTags Print File.csv”, False
End Sub
This gives me an error: Runtime Error 3051
Sub transfercsv()
DoCmd.TransferText acExportDelim, , “TblLabel01”, “V:Dealer KittingTag
Print FileTags Print File.txt”, False
End Sub
Sorry yes, I copied and pasted without updating, that’s how frustrated I
I meant the second example to end with .txt
Regards,
Diane Anderson
Do you close the table connection and the text file after the routine has finished? I tend to agree with the previous comments that it could be that the fie isn’t closed properly, or it has been opened before printing to check it.
I am assuming the V: drive is a network location, possibly on a printer server.
Personally, I would save the text file locally, then try to print it to a local printer to see if it still throws the error. It
Of course, it could be an error thrown because you have tried to save another csv file with the same name while the first one is printing.Is that possible?
Actually, here’s a radical thought and maybe Michael and I are wrong in that the lines are
supposed
to be the same. Having mentioned about opening the file in Notepad, you haven’t opened the CSV fie in Excel have you? And left it open with Excel now hidden behind other apps?
The other thought is where is the V: drive? Is it a strange permissions thing?