Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Shaun E on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Run-time Error 3011...

Status
Not open for further replies.

Rjc8513

Technical User
Feb 12, 2001
140
US
I am attempting to have the user select the folder in which to save a backup file. But, I get run-time Error 3011. Here is the code:

Dim dbs As DAO.Database
Dim fDialog As Office.FileDialog
Dim FolderName As String
Dim FileName As String

Set dbs = CurrentDb()
Set fDialog = _
Application.FileDialog(msoFileDialogFolderPicker)

With fDialog
.AllowMultiSelect = False
.Title = "Select location for backup file..."
.InitialView = msoFileDialogViewDetails
.InitialFileName = "TEMP"
If .Show = True Then
For Each FolderSelected In .SelectedItems
FolderName = FolderSelected & "\"
Next
End If
End With

FileName = "mstrarcv.txt"
DoCmd.TransferText acExportDelim, , FolderName, FileName

The error message appears on the "Do.Cmd..." line.

 
Wrong syntax of docmd.TransferText method! You don't define the table/query to export and the file path is also wrong

DoCmd.TransferText acExportDelim, YourTableHere, FolderName & "\" & FileName
 
Forgot one comma there
Sorry...


DoCmd.TransferText acExportDelim, , YourTableHere, FolderName & "\" & FileName
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top