The “Export Jobs to Text File” button’s event procedure sets up a Select Casestatement to
export the selected jobs, using the TransferTextstatement with different arguments:
Private Sub cmdExportJobs_Click()
On Error GoTo ErrorHandler
Dim intTextType As Integer
Dim strQuery As String
Dim strTextFile As String
Dim strTitle As String
Dim strPrompt As String
intTextType = Nz(Me![fraTextType].Value, 1)
strQuery = “qryFilteredJobs”
Select Case intTextType
Case 1
Comma-delimited
strTextFile = GetOutputDocsPath() _
&”Filtered Jobs.csv”
DoCmd.TransferText transfertype:=acExportDelim, _
TableName:=strQuery, _
FileName:=strTextFile, _
hasfieldnames:=True
Case 2
Fixed-width
strTextFile = GetOutputDocsPath() _
&”Filtered Jobs.txt”
strSpec = “Export@@hyFilteredJobs”
strTextFile = GetOutputDocsPath() & “Filtered Jobs.txt”
‘New style syntax
Application.CurrentProject.ImportExportSpecifications(strSpec).Ex
ecute
‘Old style syntax causes error
‘DoCmd.TransferText transfertype:=acExportFixed, _
TableName:=strQuery, _
FileName:=strTextFile, _
hasfieldnames:=True
End Select
Working with External Data 10