hi. i copied this code from someone and did some changes. it works fine to export my query to a csv-formatted file. the Save File dialog box pops up. when i choose cancel, the 2522 run-time error message appears. what can i do to suppress this message? tia.
Private Sub Command42_Click()
Dim fd As Object, csvPath As String, strCsv As String
strCsv = "MYFILE.CSV"
Set fd = Application.FileDialog(2)
With fd
.Title = "Save File As"
.ButtonName = "Save As"
.InitialFileName = CurrentProject.Path & "" & strCsv
If .Show Then
csvPath = .SelectedItems(1)
End If
End With
DoCmd.TransferText acExportDelim, , "Qpurch_detail", csvPath, False
Name strCsv As "myfile.xyz"
MsgBox "Export successful.", vbOKOnly
End Sub
Private Sub Command42_Click()
Dim fd As Object, csvPath As String, strCsv As String
strCsv = "MYFILE.CSV"
Set fd = Application.FileDialog(2)
With fd
.Title = "Save File As"
.ButtonName = "Save As"
.InitialFileName = CurrentProject.Path & "" & strCsv
If .Show Then
csvPath = .SelectedItems(1)
End If
End With
DoCmd.TransferText acExportDelim, , "Qpurch_detail", csvPath, False
Name strCsv As "myfile.xyz"
MsgBox "Export successful.", vbOKOnly
End Sub