Access 2000/2002/2003 Export To Text Bug/Safety Measure
After a frustrating afternoon trying to work out why exporting
to text was failing after converting a database from Access 97 to 2000, this
page will demonstrate what you will need to do to solve the problem.
If you are visiting this page, you are probably searching for
the words "export database or object is read-only". Anyway the problem is caused
by using a file type that is not allowed by Access 2000. Some posts on this
issue indicate that you can change the registry to fix this problem, if you find
the right registry entry, please let us all know.
Anyway in the following code, you will see how to export to a
file using the txt extension followed by a rename of the file to a new extension
(str) using the Name method. This solves the problem in a roundabout way.
Private Sub cmdXFaceSurpac_Click()
On Error GoTo Err_cmdXFaceSurpac_Click
Dim DocName As String
Const STRINGFILE As String = "face1"
Const TEXTEXT As String = ".txt"
Const STREXT As String = ".str"
DocName = "FX_XtheFaceSurpac"
DoCmd.TransferText acExportDelim, "FX_surpac", DocName, _
Me![txtFolder] & STRINGFILE & TEXTEXT, True, ""
Kill Me![txtFolder] & STRINGFILE & STREXT
Name Me![txtFolder] & STRINGFILE &
TEXTEXT As Me![txtFolder] & STRINGFILE & STREXT
MsgBox "Transfer to " & Me![txtFolder] & STRINGFILE & STREXT & " is complete.",
vbInformation, "Surpac String File"
Exit_cmdXFaceSurpac_Click:
Exit Sub
Err_cmdXFaceSurpac_Click:
MsgBox Error$
Resume Exit_cmdXFaceSurpac_Click
end sub
You can read more about this at
http://support.microsoft.com/kb/245407/en-us
Note: You can also effect Exports by modifying the
key
HKEY_LOCAL_MACHINE\Software\Microsoft\Jet\4.0\Engines\Text\DisabledExtensions
Why not try one of the articles at our website
Add a
Global Error Handler To Your Page
Replace Your File
API’s With The FileDialog Object
Click on the
button for the next
page in this Access Loop.