export qry to excel - bug? Old version issue? (1 Viewer)

madEG

Registered User.
Local time
Today, 05:15
Joined
Jan 26, 2007
Messages
309
Hello,

A user reported that when exporting a list of people from a query to excel, certain people/records are not contained in the export. I took a look (old db mdb v2002-2003 access) and what I found was quite odd.

First, I opened the resultant xls and the first 25 rows or so are blank - which I thought was weird - were these the missing records?

Next I noticed that I forgot to close the xls when rerunning/testing the export using this:

Code:
DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel9, "qryemailods", Me!Premiername, 0
When I was watching the open spreadsheet, I noticed that it was repopulated with records (I actually expected to get a 'file in use' error, but access carried on) replacing the data.

But lo' and behold! All the records were exported, including the 25 or so missing records at the top where the blank rows previously were located!?!?

Confused as to why this would happen, I tried a few things... compact and repair on the front and back end of the mdb. Save at newer version of access (2007/accdb), even working locally in case there was some network lag or other issue... Same story... when running the export with the target file closed, the first ~25 records are dropped - but if the xls is already open it runs fine.

Okaaaaaay... So now what?

I tried:

Code:
DoCmd.TransferSpreadsheet acExport, acSpreadsheetTypeExcel12, "qryemailods", Me!Premiername, 0
...and that does in fact produce the proper listing without missing records (with target file closed), but the "12" export causes the following message to pop up when opening the file:

"The file you are trying to open [filename] is in a different format than specified by the file extension. Verify that the file is not corrupted and is from a trusted source etc etc etc.. Do you want to open the file now?"

If I hit yes, the file opens and looks good - but why the error message?

I'm stumped.

Has anyone seen this before?

Ideas?

Thanks, and Happy Friday! :)
 

madEG

Registered User.
Local time
Today, 05:15
Joined
Jan 26, 2007
Messages
309
Ok, so I changed the output format to "acSpreadsheetTypeExcel12Xml" and changed the target file to the xlsx extension and my problem went away...

Why didn't I think of that earlier? :)

Thanks for looking folks - have a great weekend!
 

Users who are viewing this thread

Top Bottom