L
LJG
I have an import routine that imports files from various members, by looking
at a tblUsers, However the file now need to include a ref number.
This reference number does not belong to any table but each file will have a
different ref number and I need a way of running the import including this
number i.e.
Appointment_116_Joe_bloggs.xls
Appointment_399_Joe_bloggs.xls
Appointment_1016_Joe_bloggs.xls
Appointment_31809_Joe_bloggs.xls etc
the random number could go up to 5 digits in length
My current function is:
Function newAppointImport()
Dim db As DAO.Database
Dim rst As DAO.Recordset
Dim strSS As String
If MsgBox("You are about to import a new appointment, " & _
"Do you wish to continue?. ", vbYesNo) = vbYes Then
DoCmd.SetWarnings False
If MsgBox("New appointment about to start, " & _
"Do you wish to continue?.", vbYesNo) = vbYes Then
Set db = CurrentDb
Set rst = db.OpenRecordset("tblUser") 'the name of the table
rst.MoveFirst
Do Until rst.EOF
strSS = "C:\database\dataimports\Appointment_" _
& rst.Fields("User Name") & ".xls" 'the name of the field
If Dir(strSS) <> "" Then
DoCmd.TransferSpreadsheet acImport, 8, "tblmamprospects01", _
strSS, True, ""
End If
rst.MoveNext
Loop
rst.Close
Set rst = Nothing
Set db = Nothing
Call MsgBox("Import Completed", vbInformation Or vbDefaultButton1,
Application.Name)
End If
End If
End Function
Any suggestions would be most welcome
TIA
Les
at a tblUsers, However the file now need to include a ref number.
This reference number does not belong to any table but each file will have a
different ref number and I need a way of running the import including this
number i.e.
Appointment_116_Joe_bloggs.xls
Appointment_399_Joe_bloggs.xls
Appointment_1016_Joe_bloggs.xls
Appointment_31809_Joe_bloggs.xls etc
the random number could go up to 5 digits in length
My current function is:
Function newAppointImport()
Dim db As DAO.Database
Dim rst As DAO.Recordset
Dim strSS As String
If MsgBox("You are about to import a new appointment, " & _
"Do you wish to continue?. ", vbYesNo) = vbYes Then
DoCmd.SetWarnings False
If MsgBox("New appointment about to start, " & _
"Do you wish to continue?.", vbYesNo) = vbYes Then
Set db = CurrentDb
Set rst = db.OpenRecordset("tblUser") 'the name of the table
rst.MoveFirst
Do Until rst.EOF
strSS = "C:\database\dataimports\Appointment_" _
& rst.Fields("User Name") & ".xls" 'the name of the field
If Dir(strSS) <> "" Then
DoCmd.TransferSpreadsheet acImport, 8, "tblmamprospects01", _
strSS, True, ""
End If
rst.MoveNext
Loop
rst.Close
Set rst = Nothing
Set db = Nothing
Call MsgBox("Import Completed", vbInformation Or vbDefaultButton1,
Application.Name)
End If
End If
End Function
Any suggestions would be most welcome
TIA
Les