Code to skip transferspreadsheet if file open dialog box is cancel

Code to skip transferspreadsheet if file open dialog box is cancel

Post by TWFCZWx » Sun, 24 Oct 2004 04:31:05


Hi Again. I need VBA code to jump over my transferspreasheet function if I
click cancel instead of open from my open file dialog box logic i got from
you guys.

Private Sub cmdImportAIM_Click()
Dim strFilter As String
Dim strInputFileName As String
Dim age As Date


strFilter = ahtAddFilterItem(strFilter, "Excel Files (*.XLS)",
"*.XLS")
strInputFileName = ahtCommonFileOpenSave( _
Filter:=strFilter, OpenFile:=True, _
DialogTitle:="Please select an input file...", _
Flags:=ahtOFN_HIDEREADONLY)

'Need error handling if I cancel open file
DoCmd.TransferSpreadsheet acImport, 8, "tblAIMFund",
strInputFileName, True

End Sub

Also, Do you know how my file open requirements can be a little more
specific if i want only file names that end in " * template.xls"


--
(I can't express enough gratitude to everyone who spends time answering our
questions!)

Thanks,
Matt
(access 2000)
 
 
 

Code to skip transferspreadsheet if file open dialog box is cancel

Post by Douglas J. » Sun, 24 Oct 2004 05:18:31

To check for Cancel:

If Len(strInputFileName) = 0 Then
' Cancel was selected
Else
' do your stuff..
End If

To restrict your lookup:

strFilter = ahtAddFilterItem(strFilter, "Excel Files (*.XLS)",
"*template.XLS")


--
Doug Steele, Microsoft Access MVP
http://www.yqcomputer.com/
(no e-mails, please!)





our