Thanks for your patience! I feel like I am close.
> Is your Excel range laid out like a table, e.g.
Yes
> Does it have column headers (as above)? If so, are the headers identical
> to the names of the corresponding fields in your Access table?
Yes
> You say the Access table has more fields in it than the Excel range.
> When you import the data from Excel, do you want to leave these other
> fields empty
Yes
I'll read the links today.
Thanks again for your help!!!!

Signature
TJ Daly
> I think you'd better explain in more detail, or we'll start
> misunderstanding each other.
[quoted text clipped - 42 lines]
>
> Please respond in the newgroup and not by email.
John Nurick - 25 Feb 2006 21:35 GMT
Perhaps the simplest approach would be along these lines.
1) use the ahtCommonFileOpenSave() function from
http://www.mvps.org/access/api/api0001.htm to get the name and location
of the Excel file from the user.
2) pass this to DoCmd.TransferSpreadsheet to create a (temporary) linked
table connected to the Excel range. (I suggested using a named range.
IMHO this is the best approach if these spreadsheets are being created
from some kind of a template. Alternatively, if the range you're
interested in is guaranteed always to be in the exact same absolute
location (e.g. Sheet1!E20:I25), you can pass that instead: though it
will fail if the user has added or deleted rows or columns. Finally,
it's possible to write code that examines the contents of the workbook
to find the range you want - but that's advanced VBA.)
3) run an append query that moves the data from the linked table to the
table where you want it. To do this, you'll need to start by creating
the linked table manually (File|Get External Data|Link). Give the linked
table a name that indicates its purpose (e.g. tblTempExcelLink). Then
create an append query in the usual way, and name it something like
qryAppendExcelData.
This is "air code" and will need modification to suit your actual
circumstances.
Dim strFilter As String
Dim strInputFileName as String
Dim dbD as DAO.Database
Dim tbdT As DAO.TableDef
Const TEMP_TABLE = "tblTempExcelLink"
Const QUERY_NAME = "qryAppendExcelData"
Const IMPORT_RANGE = "RangeToImport" ' or "Sheet1!E20:I2"
' or whatever
'Get the filename
strFilter = ahtAddFilterItem(strFilter, _
"Excel Files (*.XLS)", "*.XLS")
strInputFileName = ahtCommonFileOpenSave( _
Filter:=strFilter, OpenFile:=True, _
DialogTitle:="Please select the workbook", _
Flags:=ahtOFN_HIDEREADONLY)
'Delete the temporary linked table if left over from last time
For Each tbdT In dbD.TableDefs
If tbdT.Name = TEMP_TABLE Then
DoCmd.DeleteObject acTable, TEMP_TABLE
Exit For 'No point in continuing through remaining tabledefs!
End If
Next
'Create the temporary linked table
DoCmd.TransferSpreadsheet acLink, acSpreadsheetTypeExcel9, _
TEMP_NAME, strInputFileName, True, IMPORT_RANGE
'Execute the append query
dbD.Execute QUERY_NAME, dbFailOnError
>Thanks for your patience! I feel like I am close.
>
[quoted text clipped - 10 lines]
>I'll read the links today.
>Thanks again for your help!!!!
--
John Nurick [Microsoft Access MVP]
Please respond in the newgroup and not by email.