T
ThriftyFinanceGirl
I have a procedure that runs an import based on the user choosing a file. I
want them to be able to cancel. I got the call for the common dialog from
the guys here on this group but it doesn't have error handling for the
occasion when the user chooses "cancel" instead of choosing a file.... Help?!
Don't know how to create a handler or where to put it exactly....
Public Function TaxExemptImport()
'Now open the small form that will show progress...
DoCmd.OpenForm "frmTaxExempt"
'Let's get the file name first....
Dim strFilter As String
Dim strInputFileName As String
strFilter = ahtAddFilterItem(strFilter, "Excel files (*.XLS)", "*.XLS")
strInputFileName = ahtCommonFileOpenSave( _
Filter:=strFilter, OpenFile:=True, _
DialogTitle:="Please select file to Import...", _
Flags:=ahtOFN_HIDEREADONLY)
DoCmd.SetWarnings False
Application.Echo False
'bring data into the holding table
DoCmd.TransferSpreadsheet acImport, acSpreadsheetTypeExcel9,
"TaxExemptImport", strInputFileName
============================================
Currently if the user chooses "cancel" in the Open dialog box, the code
stops on the "Docmd.TransferSpreadsheet" line. Where do I trap the error and
how?
want them to be able to cancel. I got the call for the common dialog from
the guys here on this group but it doesn't have error handling for the
occasion when the user chooses "cancel" instead of choosing a file.... Help?!
Don't know how to create a handler or where to put it exactly....
Public Function TaxExemptImport()
'Now open the small form that will show progress...
DoCmd.OpenForm "frmTaxExempt"
'Let's get the file name first....
Dim strFilter As String
Dim strInputFileName As String
strFilter = ahtAddFilterItem(strFilter, "Excel files (*.XLS)", "*.XLS")
strInputFileName = ahtCommonFileOpenSave( _
Filter:=strFilter, OpenFile:=True, _
DialogTitle:="Please select file to Import...", _
Flags:=ahtOFN_HIDEREADONLY)
DoCmd.SetWarnings False
Application.Echo False
'bring data into the holding table
DoCmd.TransferSpreadsheet acImport, acSpreadsheetTypeExcel9,
"TaxExemptImport", strInputFileName
============================================
Currently if the user chooses "cancel" in the Open dialog box, the code
stops on the "Docmd.TransferSpreadsheet" line. Where do I trap the error and
how?