H
HX
I am using the code found on mvps.org, "API: Call the standard Windows
File/Save dialog box" in a small program, and am not sure how to implement
error checking in the case that the user clicks CANCEL on the File/Save
dialog box. Doing so in my program gives a run-time error code '2522'.
Following is the module that I initiate from a macro that is invoked when a
button is pushed:
********************************
Function RunIt()
Dim strFilter As String
Dim strInputFileName As String
strFilter = ahtAddFilterItem(strFilter, "Text Files (*.txt)", "*.txt")
strInputFileName = ahtCommonFileOpenSave( _
Filter:=strFilter, OpenFile:=True, _
DialogTitle:="Please select an input file...", _
Flags:=ahtOFN_HIDEREADONLY)
DoCmd.TransferText acImportDelim, "MySpec", "MyTable", strInputFileName
End Function
*********************************
Currently, if the user clicks CANCEL on the dialog box, the run-time error
occurs because no information is being passed to DoCmd.TransferText.
So what can I put in here to check for that error, which will cause the
module to exit -- and IDEALLY, pass something back to the initiating macro
so that I can pop up a "Import Failed" message.
Even just pointing me to a tutorial online would be helpful - all my
searches for "error checking", in various forms, have resulted in people
trying to debug problems they are having with Access! Ugh!
Thanks in advance.
File/Save dialog box" in a small program, and am not sure how to implement
error checking in the case that the user clicks CANCEL on the File/Save
dialog box. Doing so in my program gives a run-time error code '2522'.
Following is the module that I initiate from a macro that is invoked when a
button is pushed:
********************************
Function RunIt()
Dim strFilter As String
Dim strInputFileName As String
strFilter = ahtAddFilterItem(strFilter, "Text Files (*.txt)", "*.txt")
strInputFileName = ahtCommonFileOpenSave( _
Filter:=strFilter, OpenFile:=True, _
DialogTitle:="Please select an input file...", _
Flags:=ahtOFN_HIDEREADONLY)
DoCmd.TransferText acImportDelim, "MySpec", "MyTable", strInputFileName
End Function
*********************************
Currently, if the user clicks CANCEL on the dialog box, the run-time error
occurs because no information is being passed to DoCmd.TransferText.
So what can I put in here to check for that error, which will cause the
module to exit -- and IDEALLY, pass something back to the initiating macro
so that I can pop up a "Import Failed" message.
Even just pointing me to a tutorial online would be helpful - all my
searches for "error checking", in various forms, have resulted in people
trying to debug problems they are having with Access! Ugh!
Thanks in advance.