473,386 Members | 1,736 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,386 software developers and data experts.

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 1854
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 thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: Jim Geissman | last post by:
I have function that returns a table of information about properties. The data comes from three different tables -- addresses (called PropertyID), property characteristics, and events concerning...
2
by: lev | last post by:
CREATE TABLE . ( NULL , , (44) ) ID is non-unique. I want to select all IDs where the last entry for that ID is of type 11.
6
by: jim_geissman | last post by:
I have encountred situations like this before, but this one has me stumped. I have a pretty simple SP that collects information about residential properties from a large database. First step is...
7
by: meltedown | last post by:
Why doesn't this return anything ? SELECT DATE_SUB('FROM_DAYS(TO_DAYS(2005-09-28 18:04:19))', INTERVAL 6 DAY)
0
by: William Wisnieski | last post by:
Hello Everyone: I'm having a very strange problem occurring with my Access 2000 database. I call it the "mystery record." Here's the story: I have a query by form that returns a record set...
10
by: Mark | last post by:
I have a table about people containing 25 fields. The table contains the usual fields - first, last, address, city, state and zip. There is no primary key. These fields all have data with the...
6
by: GaryDave | last post by:
My school registration database has not been quite right after a recent compact and repair (done while I was away). Though most of the many forms and subforms are working normally, one form in...
115
by: Mark Shelor | last post by:
I've encountered a troublesome inconsistency in the C-language Perl extension I've written for CPAN (Digest::SHA). The problem involves the use of a static array within a performance-critical...
3
by: creative1 | last post by:
Here is how you create a complex data report that involves parent and child commands and you can update information at runtime. Its pretty straight forward to work with simple queries; however,...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.