473,657 Members | 2,450 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

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_COD E], [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 1879
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.c om
http://www.accessmonster.com/Uwe/For...ccess/200611/1

Nov 22 '06 #2
Granny Spitz via AccessMonster.c om 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.c om 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
1784
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 those properties (sales, appraisals, etc.), plus a table that maps one representation of property types into another. The records are selected on the basis of location (longitude & latitude), property type, event type, and a range of event dates...
2
4573
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
1446
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 to query on the basis of address or location, and collect a temp table of property IDs. Second step is to populate a composite table of property information by joining the IDs to a table of characterisitics. Third step is to update some fields...
7
1615
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
1761
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 in a datasheet. The user double clicks on a row in that datasheet and a main form (pop up) opens bound to a table with a continuous subform bound to a query.
10
3055
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 exception of a few records missing zip. A person may be in one to five records in the database. If a person is in multiple records, the other fields in the table in each record for that person may or may not contain data. I have two problems: 1. I...
6
3069
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 particular will no longer allow new entries into the subform - the recordset of the underlying query is no longer updatable. The subform in question enters the identity and other vital info for children whose parent's ID provides the FK, linking...
115
7581
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 transform function. When compiling under gcc on my big-endian PowerPC (Mac OS X), declaring this array as "static" DECREASES the transform throughput by around 5%. However, declaring it as "static" on gcc/Linux/Intel INCREASES the throughput by...
3
18700
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, working with complex reports is tricky Assumption: Reader of this article have basic knowledge of creating data reports. Creating a Parent-Child Command and create a DataReport Suppose we have a database called company with two tables ...
0
8421
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8325
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
1
8518
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7354
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
0
4173
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4330
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2743
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
1971
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1734
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.