Link to home
Start Free TrialLog in
Avatar of daveyu
daveyu

asked on

DoCmd.OutputTo - runtime error 30016 the field 'id' is read only

Hi,

I have added the following line to the click event of an access (adp) form

 DoCmd.OutputTo acOutputQuery, "AllChecks", acFormatXLS, "c:\text.xls", True

I get the error:

DoCmd.OutputTo - runtime error 30016 the field 'id' is read only

AllChecks is a Query that I have created, that does NOT include the 'id' column
which is an identity column.

Avatar of jerryb30
jerryb30
Flag of United States of America image

What is database type you are accessing?
Can you post query?
Avatar of daveyu
daveyu

ASKER

I have an access 2002 data project, where the tables are linked to a SQL Server 2000 database.

The query will be:

select <all fields-expect 'id'> from dailyChecks

Can you give specific sql?
Can you open allchecks from normal window?
Avatar of daveyu

ASKER

sql is:

SELECT     TOP 100 PERCENT completedBy,
 completedWhen, internalEmail, internalEmailComment, internalEmailRef, externalEmail,
 externalEmailComment, externalEmailRef, accessInternet, accessInternetComment, accessInternetRef, genieWorking,
genieWorkingComment, genieWorkingRef, firstWorking, firstWorkingComment, firstWorkingRef, agressoWorking,
agressoWorkingComment, agressoWorkingRef, firstBackupComp, firstBackupCompCom, firstBackupCompRef, sysEmailBackupComp,
sysEmailBackupCompCom, sysEmailBackupCompRef, agressoBackupComp, agressoBackupCompCom, agressoBackupCompRef,
sysEmailBackupTapeChng, sysEmailBackupTapeChngCom, sysEmailBackupTapeChngRef, agressoBackupTapeChng,
agressoBackupTapeChngCom, agressoBackupTapeChngRef, firstBackupTapeChng, firstBackupTapeChngCom,
firstBackupTapeChngRef, interSiteLinksUp, interSiteLinksUpCom, interSiteLinksUpRef, allServersUp, allServersUpCom,
allServersUpRef
FROM         dbo.dailyChecks
ORDER BY completedWhen

Yes, I can open the query and incidently, access put the 'TOP 100 PERCENT' in for me.
I am at a loss.
I suspect the TOP 100 PERCENT was done because Access recognized it was dealing with SQL Server table/database.  
What happens if you go into a SQL window, and type
"select * from dbo.dailychecks;"?
I am grasping.  I have done some linking to SQL Server, but don't have one available right now to try to emulate.  Sorry
Avatar of daveyu

ASKER

no problems with typing select * from dailyChecks
Me too!.
Can you remove TOP 100 PERCENT from query and have it work?
Again, grasping.
If you can select and display all of the records, and save the sql statement, then try to manually export the data as desired.
If that works, try a macro to output, and see what that does.
Realize VBA give the ability to be more flexible.
If you continue to have problems, maybe post question to SQL Server TA.
Avatar of daveyu

ASKER

I have tried posting to sql server t/a.

No you cannot remove 'top 100' from a view with an order by clause,
if the tables are linked to a sql server database.
Avatar of daveyu

ASKER

decided to use recordset and excel object instead, works a treat
No problemo.
ASKER CERTIFIED SOLUTION
Avatar of modulo
modulo

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial