I have written a function that executes action parameter queries given a name and a list of parameters.
It splits a string into an array, passes the parameters to the (already saved) query name, then runs the query using the Execute method, etc., then writes a record to a table that logs the name of the table and whether the query works or not.
The function has worked flawlessly for over a year; I have used it in ACC2000 and ACC2002, in multiple implementations , all without error. I used it with ACC2003 a few months ago and implemented the app as an MDE. No issues.
However, in the last couple of days I have had a weird problem I’ve never seen before. Certain saved queries have been failing when run by my function. It is a random occurrence in that it does not seem to have any warning, but it does only affect a few (at the moment, four) update queries.
The weirdest part was the following:
After I had identified the queries that failed, I ran each one once, manually, typing in the same parameters that were passed by the function. Not only did the query execute with no problem, once I ran the query using the function again, the query ran fine!!!
I have programmed VBA in Access since Access 97 and have never seen this happen before. Has anyone else? Any ideas?
6 6332 Rabbit 12,516
Recognized Expert Moderator MVP
Usually, when queries are failing and I'm not getting an error message, it's because I turned off warnings in the code and didn't turn it back on. Or I'm using error catching without returning the error message.
Your queries could be failing for a number of reasons. You would have to give us the specifics of the queries and code that you're running before we can even begin to help.
Thanks for responding!
Basically, I set the query as follows ( strQueryToRun is the name of the saved
query): Dim QueryName As QueryDef 'the actual query object Set QueryName = CurrentDb.Query Defs(strQueryTo Run)
Then I run different statements based on the type of query. For action
queries, I just do the following after passing the parameters to QueryName: QueryName.Execu te
That's when the error happens. At the beginning of the function I set it to
got to a flag called ErrorHandling, which runs a SQL statement (DoCmd.RunSQL),
appending the login name, query name, and error number, if any, to a table. That's how I know which query fails since I run a few in order.
Now this function was written over a year ago, and the queries were deployed
in February without problems - I basically use this code any time I run an append, update, or delete query, to log/document any changes to data since none of my forms have the tables themselves as the record source.
If I run the query manually once, then run the query via the function,
everything works OK! I did it with the MDB, stepping through the code, then
again with the MDE. Didn't change the saved queries or the code in any way - it just worked normally after manually executing one time. One more thing I noticed this afternoon: - I ran the query once manually. No problem.
- I ran the query via the function. No problem.
- Went into Linked Table Manager and refreshed the table.
- Ran the query via the function. Failed.
- I ran the query once manually. No problem.
- I ran the query via the function. No problem.
Now, just to be sure, I checked to design of the target table and the keys were intact and everything, so I don't think it's an indexing issue keeping data from being updated(and if it was, it should fail when running the query manually, right?)
Rabbit 12,516
Recognized Expert Moderator MVP
What is the actual SQL statement that you're trying to run?
What is the SQL statement supposed to do?
What is the SQL statement doing instead?
It’s a saved query with a key field (AutoNumber type) and one text field. The query updates the text field: UPDATE tbl_ESS SET tbl_ESS.OrderNu mber = [ON]
WHERE (((tbl_ESS.ESSI D)=[ESS]));
The function (ActionParam) takes the name of the saved query( strQueryToRun) and its parameters( strParamNamesLi st, strParamValuesL ist).
It uses the Split command to put the parameter names and values into an array. Then it links each parameter value with the correct parameter: 'cycle through parameter values in array
For iCounter = LBound(arrParam Name) To UBound(arrParam Name)
strParamName = arrParamName(iC ounter)
strParamValue = arrParamValue(i Counter)
'link each parameter value with the correct parameter
QueryName.Param eters(strParamN ame) = strParamValue
Next
If the query is an action query (make-table, update, or delete) it then simply executes the query: QueryName.Execu te
But it doesn’t run the query – it immediately goes to the ErrorHandling line (On Error GoTo ErrorHandling).
Again, if I run the query manually first, then run the same query using the function, it doesn’t go to ErrorHandling – it executes the query.
What is the actual SQL statement that you're trying to run?
What is the SQL statement supposed to do?
What is the SQL statement doing instead?
I may have found an answer/workaround:
I put in a message box for the error number generated (MsgBox Err.Number) and 3622 came up.
At the MSDN library (http://msdn2.microsoft .com/en-us/library/bb178074.aspx) the error description said: You must use the dbSeeChanges option with OpenRecordset when accessing a SQL Server table that has an IDENTITY column. (Error 3622) The server-generated IDENTITY values cannot be reflected at the client side unless you use the DAO property dbSeeChanges.
I added the dbSeeChanges option to the Execute method, and the function ran with no problems (so far).
It still doesn’t explain why it runs fine after executing the query manually, though.
Rabbit 12,516
Recognized Expert Moderator MVP I may have found an answer/workaround:
I put in a message box for the error number generated (MsgBox Err.Number) and 3622 came up.
At the MSDN library (http://msdn2.microsoft .com/en-us/library/bb178074.aspx) the error description said: You must use the dbSeeChanges option with OpenRecordset when accessing a SQL Server table that has an IDENTITY column. (Error 3622) The server-generated IDENTITY values cannot be reflected at the client side unless you use the DAO property dbSeeChanges.
I added the dbSeeChanges option to the Execute method, and the function ran with no problems (so far).
It still doesn’t explain why it runs fine after executing the query manually, though.
I'm not sure about that either but I'm not a DAO expert, that's Mary. I'm glad you found your answer though. When using error handling you should have it return the message for troubleshooting purposes.
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Paul |
last post by:
I have run into a strange problem with a site I am working on. My SELECT
queries work fine, but I just tried to add an UPDATE statement and it fails.
A test showed that INSERT fails also. I created a new table just for testing
called "blah" and it had the same results.
My statements:
"UPDATE GiftCerts SET Paid=1 WHERE CertSerial='2005-0001'"
and
"INSERT INTO blah (test) VALUES ('something')"
|
by: Atreju |
last post by:
I apologize in advance for the x-post, but I am really not sure where
this would best be addressed.
I am designing a database in MSAccess for which I want to make the
front-end in VB.
I have planned out the basic structure of the tables and fields.
However, my experience with Access is limited to doing all the work
within Access, so I have a couple of issues I'm confused about.
|
by: Jerry Hull |
last post by:
I'm working with a database developed by an untrained person over
several years - and on a network that has recently been upgraded with
a new server installed and MS office upgraded from 2K (I think - it
might have been XP) to 2003. The database is impressive, both in what
it does and the obtuse and inconsistent ways it works. There are
several hundred queries, for example, with no indication of where they
are used or if they are in fact...
|
by: Lars Netzel |
last post by:
A little background:
I use three Datagrids that are in a child parent relation.
I Use Negative Autoincrement on the the DataTables and that's workning nice.
My problem is when I Update these grid and write to the database and I set
the new Primary Keys and related Fields to the new asigned atuonumbers in
the Access.
|
by: Scott Ribe |
last post by:
OK, I'm using a pool of worker threads that each have a connection (from my
own software, no PHP or anything like that involved), and a connection is in
a state where all queries fail. Looking back through the log I find the
first entry where this connection has an error (there are successful queries
on it prior, so it's not the first query):
2004-06-21 14:51:19 LOG: query: begin; set constraints all
deferred;
insert into...
| |
by: JayCallas |
last post by:
I know this question has been asked. And the usual answer is don't use
cursors or any other looping method. Instead, try to find a solution
that uses set-based queries.
But this brings up several questions / senarios:
* I created several stored procedures that take parameters and inserts
the data into the appropriate tables. This was done for easy access/use
from client side apps (i.e. web-based).
|
by: RichardP |
last post by:
Hi there everyone - I'm new to this forum.
I am having an issue when running an application from an instance of Access
which has been started through automation (early or late bound, makes no
difference).
No warning / confirmation messages are issued (eg. when running action
queries, deleting records from a datasheet, deleting database objects such as
tables).
|
by: mainframetech |
last post by:
We are having a problem with Access 2002 as opposed to Access 2000.
A multi-file query was set up under 2000 and tested good. Access is
connected through a link to an Oracle 9.1 database. The database
(mdb) was installed in
remote client machines working with Access2000 and it worked fine.
When the query was put on an Access2002 machine, it came up with
"ORA-01017 invalid logon/password", and fails. The failing machine
passes other...
|
by: marshmallowww |
last post by:
I have an Access 2000 mde application which uses ADO and pass through
queries to communicate with SQL Server 7, 2000 or 2005.
Some of my customers, especially those with SQL Server 2005, have had
pass-through queries fail due to intermittent connection failures.
I can easily restablish a connection for ADO.
My problem is with pass-through queries.
|
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...
|
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,...
| |
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, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it.
Here is my compilation command:
g++-12 -std=c++20 -Wnarrowing bit_field.cpp
Here is the code in...
|
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth.
The Art of Business Website Design
Your website is...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
|
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...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms.
Adolph will...
|
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...
| |
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| | |