Hi Rich,
I don't know of a sample database offhand, though possibly there's one
on Roger Carlson's site http://www.rogersaccesslibrary.com/
But basically all you need to is
1) create a new module in your database.
2) paste the code from the Access Web (from the line marked Code Start
to the line marked Code End) into the module and save it (call it
something like vbOpenFile.
3) to make it work, put a commandbutton on a form. Name the button
something like cmdOpenFile. Set the button's Click property to [Event
Procedure], and click the adjacent [...] button. This fires up the VBE
editor and inserts the skeleton code:
Private Sub cmdOpenFile_Click()
End Sub
4) Now paste the following (which is copied from the same Access Web
page) into the skeleton:
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)
The statement beginning "strInputFileName" displays the File Open dialog
and puts the path and name of the selected file into that variable. So
the next thing is to use this name to import the data, which needs one
more VBA statement, something like this (but you'll have to adjust the
table name etc.)
DoCmd.TransferSpreadsheet acImport, _
acSpreadsheetTypeExcel9, "MyTable", strInputFileName, True
On Mon, 16 Aug 2004 12:17:48 -0700,
>Thanks John for the response, but I'll be honest with you,
>I know very little about VB. I was researching this issue
[quoted text clipped - 37 lines]
>>Please respond in the newgroup and not by email.
>>.
--
John Nurick [Microsoft Access MVP]
Please respond in the newgroup and not by email.