Hi Doug,
Well, to be honest I use this newsgroup the most. You
may want to do a new post in the Importing/Exporting
group in Access, or look for a similar one under Excel,
to see what suggestions you receive if nothing in this
message helps solve the problem.
There will likely be many ways that you can approach
this, so if you do a follow-up post it may help to
include some info on what your internal process will be.
For example, it may make a big difference whether you
have control of the excel file to start with rather than
being stuck with whatever you receive from another
group. Other considerations that would be helpful are
things such as how often the file will get filled out,
what you need to do with it, etc.
Usually when I am looking into something like this I will
use Google to search the newsgroups because it works much
better than the search offered by the Microsoft site. If
you haven't done this, you can go to the following link:
http://groups.google.com/groups?hl=en&lr=&ie=UTF-8&oe=UTF-
8&group=microsoft.public.access
In doing a quick search, I found a few interesting prior
posts:
http://groups.google.com/groups?hl=en&lr=&ie=UTF-
8&threadm=ekbRBDtFEHA.3188%
40TK2MSFTNGP09.phx.gbl&rnum=4&prev=/groups%3Fhl%3Den%26lr%
3D%26ie%3DUTF-8%26q%3Dimport%2Bexcel%2Baccess%2Bwrong%
2Bformat%2Bgroup%253Amicrosoft.public.*%26btnG%3DSearch%
26meta%3Dgroup%253Dmicrosoft.public.access.*
http://groups.google.com/groups?hl=en&lr=&ie=UTF-
8&threadm=3912b7d9.2212787%
40news.proaxis.com&rnum=4&prev=/groups%3Fnum%3D20%26hl%
3Den%26lr%3D%26ie%3DUTF-8%26q%3Dexcel%2Baccess%2Bconnect%
2Bcreatetabledef%2Bgroup%253Amicrosoft.public.*%26btnG%
3DSearch
A few ideas for you to consider:
The best way of handling this may be to just enter the
ID's as numbers and leave out the leading zero's. The
leading zero's can be displayed in access by just setting
the format to "0000" where the number of zero's equals
the number of digits in the employee ID. You could also
probably use this format in Excel for the display,
although I'm not sure if that would throw off the import
and/or linking.
As mentioned in one of the posts above, there is
apparently an IMEX setting in the registry that will
determine whether mixed fields are imported as text, or
as the most prevalent type, you may be able to change
yours to text.
There is an alternative method for linking to a database
by connecting to the excel file as a database and using
the createtabledef method to create a table definition
for the worksheet and then appending this to the tables
collection of the Access Database. This may give
different results than the transferdatabase command. I
think that the connection also may allow you to set the
IMEX mode.
You may be able to import your numbers as text by typing
an apostrophe before all of the entries in the problem
field.
You may also be able to work with the Excel file as a CSV
file. When Excel opens CSV files, they look like
standard spreadsheets, but are actually saved in CSV
format. If the CSV format would be useable on the Excel
side, you would have control over the field formatting
when importing to Access (unlike Excel sheets, Access
lets you explicitly specify the field formats for text
files, and you can save the specification after doing it
once for use with the transfertext command).
Similarly, you may be able to use VBA to automate the
export of the Excel data to a text file, and then the
import of the resulting text file.
Finally, I can't remember if you already tried importing
rather than linking, but one of the posts that I saw said
that Excel uses a slightly different method for importing
rather than linking. Also, if you import you may be able
to change the table properties to specify text for the
Employee ID. Similarly, you may be able to just always
use this table as a temp table where you delete records
prior to import, then import as an append to the table,
then query new employee id's to your permanent table.
I would try to look for the easiest approaches first,
before resigning to connecting to the worksheet and
reading the contents cell by cell, but that is an option
if necessary.
Sorry I could't be more help. Hopefully one of the above
ideas may pan out, or, if not, hopefully you can get
further help from the newsgroup.
-Ted Allen