File Box

A

AJOLSON

I am having a heck of a time getting fileDiolog box to open so a user can
select a file to import into an access tbl. I am using the following code
but get a compile error stating that ahtAddfilterItem "Sub or Function Not
defined"

Dim strFilter As String
Dim strInputFileName As String

strFilter = ahtAddFilterItem(strFilter, "Excel Files (*.XLS)", "*.XLS")
strInputFileName = ahtCommonFileOpenSave( _
Filter:=strFilter, OpenFile:=True, _
DialogTitle:="Please select an input file...", _
Flags:=ahtOFN_HIDEREADONLY)
'strInputFileName contains the full path to whatever file was selected.
Using C:\Test" as the path am I way off base for what I want to do?

In a prefect world the user would select a file from that folder( excel
file) and it would load into a table. What code would I use to achive this?

thanks
Andy
 
D

Dirk Goldgar

AJOLSON said:
I am having a heck of a time getting fileDiolog box to open so a user can
select a file to import into an access tbl. I am using the following code
but get a compile error stating that ahtAddfilterItem "Sub or Function
Not
defined"

Dim strFilter As String
Dim strInputFileName As String

strFilter = ahtAddFilterItem(strFilter, "Excel Files (*.XLS)", "*.XLS")
strInputFileName = ahtCommonFileOpenSave( _
Filter:=strFilter, OpenFile:=True, _
DialogTitle:="Please select an input file...", _
Flags:=ahtOFN_HIDEREADONLY)
'strInputFileName contains the full path to whatever file was selected.
Using C:\Test" as the path am I way off base for what I want to do?

In a prefect world the user would select a file from that folder( excel
file) and it would load into a table. What code would I use to achive
this?

thanks
Andy


That looks like code that started life here:

http://www.mvps.org/access/api/api0001.htm

Have you pasted all the code from that article into a module in your
database?
 
A

AJOLSON

OOPS did not read the whole code.

now it opens up the "My Doucments" folder. However, I want it to open to
another folder but cant fine where to put the referance to the folder I want
opend. Example I want C:\Files to open and display all the Excel files in
that folder. How is that achived?
 
D

Dirk Goldgar

AJOLSON said:
OOPS did not read the whole code.

now it opens up the "My Doucments" folder. However, I want it to open to
another folder but cant fine where to put the referance to the folder I
want
opend. Example I want C:\Files to open and display all the Excel files in
that folder. How is that achived?


strInputFileName = ahtCommonFileOpenSave( _
Filter:=strFilter, OpenFile:=True, _
DialogTitle:="Please select an input file...", _
InitialDir:="C:\Files", _
Flags:=ahtOFN_HIDEREADONLY)
 
A

AJOLSON

Ok ingore my last response as I have it opening to the correct directory.

Now the last part. The user will be opening a excel file and loading the
content of the Sheet1 into a table within access called Raw Data.


SO after the user has selected the file they want how do I get it to load
into the table in access?
 
A

AJOLSON

Ok so now egnore the last part as I figure out how to load into a table. If
anyone wants to know here is how it is done

'Opens the folder
strFilter = ahtAddFilterItem(strFilter, "Excel Files (*.XLS)", "*.XLS")
strInputFileName = ahtCommonFileOpenSave( _
Filter:=strFilter,
InitialDir:="\\bhihnbwfa01\Groups\HR\Weeklies", _
DialogTitle:="Please select an input file...", _
Flags:=ahtOFN_HIDEREADONLY)

' Tranfers it to a table

DoCmd.TransferSpreadsheet acImport, acSpreadsheetTypeExcel8, "Raw Data",
strInputFileName, False, "Both Headcount and Exclusions$"
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top