carterlw12
Registered User.
- Local time
- Today, 17:39
- Joined
- Oct 2, 2018
- Messages
- 25
Is there a way during my import that I can specify that it only imports if it matches a certain word in the file name?
I'm using:
I'm using:
Code:
Private Sub cmdImport_Click()
Dim FSO As New FileSystemObject
Dim strSQL As String
strSQL = "INSERT INTO PeopleSoft_Import_tbl (GlobalID, RecordEffDate, BirthDate, HireDate, ReHireDate, ServiceDate, SeniorityDate, TermDate, ShortName, FirstName, LastName, MI, Supervisor, EmpStatus, StatusEffDate, [FT/PT], [Reg/Temp], HomePhone, WorkPhone, PersonalEmail, WorkEmail, Region, Country, Division, Location, Dept, Job, JobLevel, [Union], FLSAInd, PayGroup, TipInd, EmployeeClass, BaseWageRate, BaseWageEffDate, WeeklyHours, ADPFile, PTOPrem, Language, Address, City, State, ZipCode, Country2, [Currency], PIS, LocalID, FileName) SELECT F1, F2, F3, F4, F5, F6, F7, F8, F9, F10, F11, F12, F13, F14, F15, F16, F17, F18, F19, F20, F21, F22, F23, F24, F25, F26, F27, F28, F29, F30, F31, F32, F33, F34, F35, F36, F37, F38, F39, F40, F41, F42, F43, F44, F45, F46, F47, F48 FROM PeopleSoft_staging_tbl;"
If Nz(Me.txtFilepath, "") = "" Then
MsgBox "No file has been selected. Please select a file."
Exit Sub
End If
If FSO.FileExists(Nz(Me.txtFilepath, "")) Then
DoCmd.TransferText acImportDelim, , "PeopleSoft_staging_tbl", Me.txtFilepath, False
CurrentDb.Execute "UPDATE PeopleSoft_staging_tbl SET F48 = '" & _
Right(txtFilepath, 24) & "' WHERE F48 IS NULL", dbFailOnError
CurrentDb.Execute strSQL, dbFailOnError
CurrentDb.Execute "DELETE FROM PeopleSoft_staging_tbl"
MsgBox "Import Successful!"
txtFilepath.Value = ""
Exit Sub
End If
End Sub