468,770 Members | 2,314 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 468,770 developers. It's quick & easy.

A mystery: create table query doesn't create table from code

Hello

Why do you think a create table query doesn't create table from the
following code?

Set myQuery = myDB.QueryDefs("qryCON absent adults previous day log")
myQuery.Execute

If I execute the query myself, it creates the table perfectly well.
When executed from code, an error is 3061: too few parameters. Expected
1.

The query is:

SELECT [qryCON absent students per day].[PERSON_CODE], [qryCON absent
students per day].[DAY], [qryCON absent students per day].[START_TIME],
[qryCON absent students per day].[SBJ_CODE_P], [qryCON absent students
per day].[CAL_OCC_P], [qryCON absent students per
day].[FES_SPONSOR_CODE], [qryRegister Student Comments].[EVENT_DATE],
[qryRegister Student Comments].[Expr1] AS Comment INTO [tblCON absent
students per day]
FROM ([qryCON absent students per day] INNER JOIN [qryCON Absent
students per day >2] ON [qryCON absent students per
day].[PERSON_CODE]=[qryCON Absent students per day >2].[PERSON_CODE])
LEFT JOIN [qryRegister Student Comments] ON [qryCON absent students per
day].[PERSON_CODE]=[qryRegister Student Comments].[StuCode];

As you can see, it is based on 3 other queries. If it works on it's
own, it surely should work from code.

Any help will be greatly appreciated.

Thank you.

Nov 22 '06 #1
3 1632
Galka wrote:
If it works on it's
own, it surely should work from code.
No, if it contains brackets to fix syntax errors and is copied somewhere else,
it *might* work but it's not guaranteed. Avoid syntax errors by only using
alphanumeric characters and the underscore in names, and don't use reserved
words like day as a name. Then see if your query works.

--
Message posted via AccessMonster.com
http://www.accessmonster.com/Uwe/For...ccess/200611/1

Nov 22 '06 #2
Granny Spitz via AccessMonster.com wrote:
Galka wrote:
If it works on it's
own, it surely should work from code.

No, if it contains brackets to fix syntax errors and is copied
somewhere else, it *might* work but it's not guaranteed. Avoid
syntax errors by only using alphanumeric characters and the
underscore in names, and don't use reserved words like day as a name.
Then see if your query works.
Also, queries run in the Access GUI can use the Expression Service to resolve
certain expressions like form references and calls to certain VBA functions.
The same query run in code does not have the Expression Service at its disposal.

--
Rick Brandt, Microsoft Access MVP
Email (as appropriate) to...
RBrandt at Hunter dot com
Nov 22 '06 #3
Thank you to both of you gentlemen.
Your explanation opened my eyes. I have got such mysteries now and then
over the years and never could understand why.
Galina

Rick Brandt wrote:
Granny Spitz via AccessMonster.com wrote:
Galka wrote:
If it works on it's
own, it surely should work from code.
No, if it contains brackets to fix syntax errors and is copied
somewhere else, it *might* work but it's not guaranteed. Avoid
syntax errors by only using alphanumeric characters and the
underscore in names, and don't use reserved words like day as a name.
Then see if your query works.

Also, queries run in the Access GUI can use the Expression Service to resolve
certain expressions like form references and calls to certain VBA functions.
The same query run in code does not have the Expression Service at its disposal.

--
Rick Brandt, Microsoft Access MVP
Email (as appropriate) to...
RBrandt at Hunter dot com
Nov 23 '06 #4

This discussion thread is closed

Replies have been disabled for this discussion.

Similar topics

2 posts views Thread by lev | last post: by
6 posts views Thread by jim_geissman | last post: by
7 posts views Thread by meltedown | last post: by
reply views Thread by William Wisnieski | last post: by
115 posts views Thread by Mark Shelor | last post: by
1 post views Thread by CARIGAR | last post: by
reply views Thread by zhoujie | last post: by
1 post views Thread by Marin | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.