dougf1r
asked on
Select Excel File for Import with Form Button
With Access 2007, I have successfully used this code in the past to open a Browse... window for importing Excel files with a form button.
However, I am now using Access 2010 and I receive the error "Method or data member not found" in association with "txtFileName".
I am not sure if it is the newer version of Access (or something else) that is causing this.
Does anyone have a suggestion for how to get this function working? I am willing to try a whole new set of code if that is what will be necessary.
Private Sub SelectSurvey_Click()
Dim strStartDir As String
Dim strFilter As String
Dim lngFlags As Long
' Lets start the file browse from our current directory
strStartDir = CurrentDb.Name
strStartDir = Left(strStartDir, Len(strStartDir) - Len(Dir(strStartDir)))
strFilter = ahtAddFilterItem(strFilter, _
"Excel Files (*.xls)", "*.xls")
Me.txtFileName = ahtCommonFileOpenSave(InitialDir:=strStartDir, _
Filter:=strFilter, FilterIndex:=3, flags:=lngFlags, _
DialogTitle:="Select File")
End Sub
However, I am now using Access 2010 and I receive the error "Method or data member not found" in association with "txtFileName".
I am not sure if it is the newer version of Access (or something else) that is causing this.
Does anyone have a suggestion for how to get this function working? I am willing to try a whole new set of code if that is what will be necessary.
I would try to import the spreadsheet first (You can delete after) then save the import name as "ahtCommonFileOpenSave" at the last step (check Save Import Steps). I had that same issue before and that was a work around.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
Indeed, I had forgotten to bring over the textbox named "txtFileName". I added that back in and it works now.
Thanks Rey!
Thanks Rey!
See this link for more information: http://access.mvps.org/access/api/api0001.htm