I have a update query which updates correctly in the query window, but
not when executed in vba.
The VBA is
================================================== ====
strSQL = "UPDATE [tblReference_Ticket_PN_and_RootCause] " & _
"INNER JOIN [tblCurrentResults] " & _
"ON [tblReference_Ticket_PN_and_RootCause].[Ticket
Number]=[tblCurrentResults].[Ticket Number] " & _
"SET [tblReference_Ticket_PN_and_RootCause].[Product Name]= '" &
rstProductName("ProductName").Value & "', " & _
"[tblReference_Ticket_PN_and_RootCause].[ProductNameDrillDown]= '" &
rstProductName("ProductNameDrillDown").Value & "' " & _
"WHERE [tblCurrentResults].[Product Name] LIKE '%" &
rstProductName("ProductNameMatch").Value & "%' " & _
"AND nz([tblReference_Ticket_PN_and_RootCause].[Product
Name],'')='';"
Debug.Print strSQL
DoCmd.RunSQL strSQL
================================================== ====
strSQL captured from the immediate window (with a couple of carriage
returns thrown in)
================================================== ====
UPDATE [tblReference_Ticket_PN_and_RootCause]
INNER JOIN [tblCurrentResults]
ON [tblReference_Ticket_PN_and_RootCause].[Ticket
Number]=[tblCurrentResults].[Ticket Number]
SET [tblReference_Ticket_PN_and_RootCause].[Product Name]= 'P2P',
[tblReference_Ticket_PN_and_RootCause].[ProductNameDrillDown]= 'P2P'
WHERE [tblCurrentResults].[Product Name] LIKE '%P2P%'
AND nz([tblReference_Ticket_PN_and_RootCause].[Product Name],'')='';
================================================== ====
When I copy the sql from the immediate window, paste it in a query
window, and replace the "%" with "*", it works (I update 5000+ rows).
After resetting the data, the VBA version runs, but updates 0 rows.
I thought I found the answer with the "%" to "*" switch, but that
doesn't seem to be it. I'm stumped; any help out there?
Thanks,
Steve 2 1409 sp*****@gmail.com wrote:
I have a update query which updates correctly in the query window, but
not when executed in vba.
The VBA is
================================================== ====
strSQL = "UPDATE [tblReference_Ticket_PN_and_RootCause] " & _
"INNER JOIN [tblCurrentResults] " & _
"ON [tblReference_Ticket_PN_and_RootCause].[Ticket
Number]=[tblCurrentResults].[Ticket Number] " & _
"SET [tblReference_Ticket_PN_and_RootCause].[Product Name]= '" &
rstProductName("ProductName").Value & "', " & _
"[tblReference_Ticket_PN_and_RootCause].[ProductNameDrillDown]= '" &
rstProductName("ProductNameDrillDown").Value & "' " & _
"WHERE [tblCurrentResults].[Product Name] LIKE '%" &
rstProductName("ProductNameMatch").Value & "%' " & _
"AND nz([tblReference_Ticket_PN_and_RootCause].[Product
Name],'')='';"
Debug.Print strSQL
DoCmd.RunSQL strSQL
================================================== ====
strSQL captured from the immediate window (with a couple of carriage
returns thrown in)
================================================== ====
UPDATE [tblReference_Ticket_PN_and_RootCause]
INNER JOIN [tblCurrentResults]
ON [tblReference_Ticket_PN_and_RootCause].[Ticket
Number]=[tblCurrentResults].[Ticket Number]
SET [tblReference_Ticket_PN_and_RootCause].[Product Name]= 'P2P',
[tblReference_Ticket_PN_and_RootCause].[ProductNameDrillDown]= 'P2P'
WHERE [tblCurrentResults].[Product Name] LIKE '%P2P%'
AND nz([tblReference_Ticket_PN_and_RootCause].[Product Name],'')='';
================================================== ====
When I copy the sql from the immediate window, paste it in a query
window, and replace the "%" with "*", it works (I update 5000+ rows).
After resetting the data, the VBA version runs, but updates 0 rows.
I thought I found the answer with the "%" to "*" switch, but that
doesn't seem to be it. I'm stumped; any help out there?
Thanks,
Steve
In VBA you also need to use * instead of % unless you are using ADO.
--
Rick Brandt, Microsoft Access MVP
Email (as appropriate) to...
RBrandt at Hunter dot com
Well the following certainly works
strSQL = "UPDATE tblReference_Ticket_PN_and_RootCause AS rc " _
& "INNER JOIN tblCurrentResults AS cr " _
& "ON rc.[Ticket Number] = cr.[Ticket Number] " _
& "SET rc.[Product Name] = 'P2P', " _
& "rc.ProductNameDrillDown = 'P2P' " _
& "WHERE cr.[Product Name] Like '*P2P*' " _
& "AND nz([rc].[Product Name],'')='';"
currentdb.execute strSQL
Note * not %
--
Terry Kreft
<sp*****@gmail.comwrote in message
news:11**********************@m79g2000cwm.googlegr oups.com...
I have a update query which updates correctly in the query window, but
not when executed in vba.
The VBA is
================================================== ====
strSQL = "UPDATE [tblReference_Ticket_PN_and_RootCause] " & _
"INNER JOIN [tblCurrentResults] " & _
"ON [tblReference_Ticket_PN_and_RootCause].[Ticket
Number]=[tblCurrentResults].[Ticket Number] " & _
"SET [tblReference_Ticket_PN_and_RootCause].[Product Name]= '" &
rstProductName("ProductName").Value & "', " & _
"[tblReference_Ticket_PN_and_RootCause].[ProductNameDrillDown]= '" &
rstProductName("ProductNameDrillDown").Value & "' " & _
"WHERE [tblCurrentResults].[Product Name] LIKE '%" &
rstProductName("ProductNameMatch").Value & "%' " & _
"AND nz([tblReference_Ticket_PN_and_RootCause].[Product
Name],'')='';"
Debug.Print strSQL
DoCmd.RunSQL strSQL
================================================== ====
strSQL captured from the immediate window (with a couple of carriage
returns thrown in)
================================================== ====
UPDATE [tblReference_Ticket_PN_and_RootCause]
INNER JOIN [tblCurrentResults]
ON [tblReference_Ticket_PN_and_RootCause].[Ticket
Number]=[tblCurrentResults].[Ticket Number]
SET [tblReference_Ticket_PN_and_RootCause].[Product Name]= 'P2P',
[tblReference_Ticket_PN_and_RootCause].[ProductNameDrillDown]= 'P2P'
WHERE [tblCurrentResults].[Product Name] LIKE '%P2P%'
AND nz([tblReference_Ticket_PN_and_RootCause].[Product Name],'')='';
================================================== ====
When I copy the sql from the immediate window, paste it in a query
window, and replace the "%" with "*", it works (I update 5000+ rows).
After resetting the data, the VBA version runs, but updates 0 rows.
I thought I found the answer with the "%" to "*" switch, but that
doesn't seem to be it. I'm stumped; any help out there?
Thanks,
Steve This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: Warren Wright |
last post by:
Hi group,
I have a select statement that if run against a 1 million record
database directly in query analyzer takes less than 1 second.
However, if I execute the select statement in a stored...
|
by: Jack |
last post by:
Hi,
I have a stored access query which is corresponding to a particular id.
However, I am using a login script to capture the value of an id. Now, I want
to dynamically open the stored query by...
|
by: Darryl Kerkeslager |
last post by:
In the FE mdb I put two variables in a module:
Private selectedFromDate As Date
Private selectedToDate As Date
I create functions/subs:
Public Sub SetSelectedFromDate(fromDate As Date)...
|
by: Dino L. |
last post by:
How can I run stored procedure (MSSQL) ?
|
by: Crash |
last post by:
C#
VS 2003
..Net Framework V1.1 SP1
SQL Server 2000 SP3
Enterprise Library June 2005
I'm working with some code {not of my creation} that performs the
following sequence of actions:
- Open...
|
by: ric_deez |
last post by:
Hi there, I would like to create a simple search form to allow users to
search for a job number based on a number of parameters. I think I
understand how to use parameteres associated with Stored...
|
by: jullus |
last post by:
hi everyone
yesterday was my first day working with MySQL
so i have installed MySQL 5.0.19 and MySQL administrator and query browser
in MySQL admin i created a table and i edited it in MySQL query...
|
by: Frawls |
last post by:
Hi
I Am am having problems with a stored Procedure that i wrote.
Basically whats happening is that the Stored procedure Runs fine when i
EXECUTE it in SQL Query analyzer.
But when i debug...
|
by: ADezii |
last post by:
One frequently asked question at TheScripts is "Should I use a Stored Query or an SQL Statement in those situations that require a Query (RecordSets, RecordSources, Append, Delete, Update Operations,...
|
by: aCe |
last post by:
hi all,
i need to convert these simple PHP code into stored procedure :
<?php
$result = mssql_query( "SELECT whid, whcode FROM warehouse" );
while( $wh = mssql_fetch_object( $result ) )
{...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
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...
|
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...
|
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
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
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...
|
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...
|
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,...
|
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...
| | |