Access.2007.VBA.Bibl..

(John Hannent) #1
Application.CurrentProject.ImportExportSpecifications(strSpec).
Execute

‘Old style syntax causes error
‘DoCmd.TransferText transfertype:=acImportFixed, _
specificationname:=strSpec, _
TableName:=strTable, _
FileName:=strTextFile, _
hasfieldnames:=True

End Select

Assign table as the subform’s source object.


Me![subNewJobs].SourceObject = “fsubNewJobs”

ErrorHandlerExit:
Exit Sub

ErrorHandler:
MsgBox “Error No: “ & Err.Number _
& “; Description: “ & Err.Description
Resume ErrorHandlerExit

End Sub

The “Save New Jobs to Table” command button’s event procedure runs an append query that adds
the selected jobs to tblNewJobs:


Private Sub cmdSaveJobs_Click()

On Error GoTo ErrorHandler

DoCmd.SetWarnings False
DoCmd.OpenQuery “qappNewJobs”
strTitle = “Jobs imported”
strPrompt = “New jobs imported into tblJobs from “ _
& GetTextFile()
MsgBox strPrompt, vbInformation + vbOKOnly, strTitle

ErrorHandlerExit:
Exit Sub

ErrorHandler:
MsgBox “Error No: “ & Err.Number _
& “; Description: “ & Err.Description
Resume ErrorHandlerExit

End Sub

Working with External Data 10

Free download pdf