Public Function ImportExport(ByVal Ltype As String, ByVal Tname As String, _
ByVal TLoc As String) As Long
On Error GoTo Err_handler
Debug.Print Ltype & " File " & TLoc
Select Case Ltype:
Case "acImport":
Ltype = 0
Case "acExport":
Ltype = 1
Case "acLink":
Ltype = 2
End Select
DoCmd.TransferSpreadsheet Ltype, 8, Tname, TLoc, True, ""
Exit Function
Err_handler:
Select Case Err.Number:
Case 2391:
MsgBox Err.Number & " One or more fields in " & TLoc & " not in Database"
Case 3051:
' Somebody is in the xls
Case Else
Debug.Print Err.Number & " " & Err.Description
End Select
ImportExport = Err.Number
Err.Clear
End Function