Macro to create export delimited file and print total report.

N

notanexpert

I'm new at designing access databases. I created a command button to execute
a macro to create an export file and print a report. The first time I
clicked the button, the report printed but I couldn't find the export file.
Now when I click the button, it gives me the following message: Can't
update. Database or object is read-only. I haven't set anything to be
read-only at this point. How do I pinpoint where the problem is or what do I
change to fix this?

Thanks, Jackie
 
N

notanexpert

Ken - the following are the 2 actions it's supposed to perform:

TransferText
OpenReport

The 'Action Failed' message I get is on the action TransferText and the
arguments are:

2,Bills to IS,qryBills to IS,c:\temp\periodic.prn,No,,

Thanks!! Jackie
 
K

Ken Snell \(MVP\)

You cannot export data to a file whose extension is .prn.

For security reasons, newer versions of ACCESS will not import or export
(via TransferText) text files with nonstandard files extensions -- the only
file extensions that can be used for text files for ACCESS to import them
are ".txt", ".csv", ".tab", and ".asc". To handle a ".prn" file extension,
see these Knowledge Base articles:

ACC2000: Importing or Linking a Text File Fails for a File That Does Not
Have a Valid File Name Extension
http://support.microsoft.com/default.aspx?id=304206

ACC2000: "Can't Update. Database or Object Is Read-only" Error Message When
You Import or Export Files
http://support.microsoft.com/default.aspx?scid=kb;[LN];245407

ACC2000: How to Import a Text File That Has an Extension That Access Does
Not Recognize
http://support.microsoft.com/?id=306144

(The renaming of the file is the preferred method.)


One other note: a macro will not let you rename a file after it's exported.
You'd need to use VBA code for that. You can programmatically change the
exported text file's extension after the text file export is done. See Name
statement in VBA help file.

Example:
Name "C:\FolderName\TextFileName.txt" As
"C:\FolderName\TextFileName.prn"
 
N

notanexpert

Ken - Thank you!! That explains why it worked in the old program (Access 97)
& not this one. I will see what I can do with the VBA.

Jackie

Ken Snell (MVP) said:
You cannot export data to a file whose extension is .prn.

For security reasons, newer versions of ACCESS will not import or export
(via TransferText) text files with nonstandard files extensions -- the only
file extensions that can be used for text files for ACCESS to import them
are ".txt", ".csv", ".tab", and ".asc". To handle a ".prn" file extension,
see these Knowledge Base articles:

ACC2000: Importing or Linking a Text File Fails for a File That Does Not
Have a Valid File Name Extension
http://support.microsoft.com/default.aspx?id=304206

ACC2000: "Can't Update. Database or Object Is Read-only" Error Message When
You Import or Export Files
http://support.microsoft.com/default.aspx?scid=kb;[LN];245407

ACC2000: How to Import a Text File That Has an Extension That Access Does
Not Recognize
http://support.microsoft.com/?id=306144

(The renaming of the file is the preferred method.)


One other note: a macro will not let you rename a file after it's exported.
You'd need to use VBA code for that. You can programmatically change the
exported text file's extension after the text file export is done. See Name
statement in VBA help file.

Example:
Name "C:\FolderName\TextFileName.txt" As
"C:\FolderName\TextFileName.prn"


--

Ken Snell
<MS ACCESS MVP>



notanexpert said:
Ken - the following are the 2 actions it's supposed to perform:

TransferText
OpenReport

The 'Action Failed' message I get is on the action TransferText and the
arguments are:

2,Bills to IS,qryBills to IS,c:\temp\periodic.prn,No,,

Thanks!! Jackie
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top