Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > Database > SQL Language
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
SQL Language SQL Language discussions not specific to a particular RDBMS program or vendor.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the SQL Language section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old February 10th, 2010, 05:10 AM
Authorized User
Points: 308, Level: 6
Points: 308, Level: 6 Points: 308, Level: 6 Points: 308, Level: 6
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: May 2009
Posts: 50
Thanks: 0
Thanked 0 Times in 0 Posts
Default Update query doesnt run when Select query does (In MS Access)

In MS Access I am trying to update a field (memo) to equal the previous entry for the memo field plus some text and the value of the AltPhone field when the AltPhone field is not empty. When I run it as a select query I get the answer I want. When I change it to an update query, it does not work. Does anyone know why?

My logic is that I try to set a new field name in the query to be the calculation and then make the memo field update to the contents of this new field.

Memo is in the Customer table, Alt Phone is in the actexcel011610 table. Both tables have an OO field (stands for original order - don't ask) which is the join field.

The SQL version (I created this in the Access query graphical interface) is (and which clearly ignores the defining of the calculation for the MemoCombined field):

UPDATE actexcel011610 INNER JOIN Customer ON actexcel011610.OO = Customer.OO SET Customer.[Memo] = [memoCombined]
WHERE (((actexcel011610.[Alt Phone]) Is Not Null));


In the graphical design section, I define the MemoCombined shows as
MemoCombined: IIf([memo]<>"",[memo] & ", Alt phone is " & [alt phone],"Alt phone is " & [alt phone])

When run as a Select query, the above MemoCombined section runs perfectly, with the SQL code as:

SELECT IIf([memo]<>"",[memo] & ", Alt phone is " & [alt phone],"Alt phone is " & [alt phone]) AS MemoCombined, Customer.Memo, actexcel011610.OO
FROM actexcel011610 INNER JOIN Customer ON actexcel011610.OO = Customer.OO
WHERE (((actexcel011610.[Alt Phone]) Is Not Null));



So I then tried to break it into two steps. First I ran a select query so I got the field of MemoCombined calculated. Then ran what seemed a simpler query based on the select query and the Customer table, trying to change [customer].[memo] to the MemoCombined value. And still it did not work. The SQL on this attempt is:

UPDATE Customer INNER JOIN Set_MemoCombined_Value ON Customer.OO = Set_MemoCombined_Value.OO SET Customer.[Memo] = [memocombined]
WHERE (((Customer.Memo) Is Null));

What am I doing wrong? I am not very skilled in SQL and generally rely on the Access graphical interface to set up my queries.

If it helps, the Memo field currently has only about 10 our of 6000 records with entries. And Alt Phone field has 11 entries.
Reply With Quote
  #2 (permalink)  
Old February 10th, 2010, 08:43 AM
Friend of Wrox
Points: 7,395, Level: 36
Points: 7,395, Level: 36 Points: 7,395, Level: 36 Points: 7,395, Level: 36
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: Jun 2003
Location: Capital Federal, , Argentina.
Posts: 2,189
Thanks: 5
Thanked 59 Times in 57 Posts
Send a message via MSN to gbianchi
Default

HI there..

If the query doesn't run, you probably receive an error. Can you put it here??

Also, it's usually not posible to update query that contains joins. The error is about it???
__________________
HTH

Gonzalo


================================================== =========
Read this if you want to know how to get a correct reply for your question.
(Took that from Doug signature and he Took that from Peter profile)
================================================== =========
My programs achieved a new certification :
WORKS ON MY MACHINE
================================================== =========
I know that CVS was evil, and now i got the
proof.
================================================== =========
Reply With Quote
  #3 (permalink)  
Old February 10th, 2010, 10:48 PM
Friend of Wrox
 
Join Date: Jun 2008
Location: Snohomish, WA, USA
Posts: 1,649
Thanks: 3
Thanked 141 Times in 140 Posts
Default

I don't believe that Access allows you to use a MEMO field like that. See, it's possible to end up needing a buffer bigger than all of memory when you try to UPDATE a MEMO field based on its prior contents.
Reply With Quote
  #4 (permalink)  
Old February 11th, 2010, 04:54 AM
Authorized User
Points: 308, Level: 6
Points: 308, Level: 6 Points: 308, Level: 6 Points: 308, Level: 6
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: May 2009
Posts: 50
Thanks: 0
Thanked 0 Times in 0 Posts
Default What I mean by a memo field

This is not a field of memo type. It is a normal text field that is used to record internal notes (as in memos to self).
Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
MS Access Query neha2007 SQL Language 1 July 12th, 2007 10:11 AM
ms access query umeshtheone VB Databases Basics 1 June 1st, 2007 10:27 AM
MS Access Query rsm42 ASP.NET 1.0 and 1.1 Basics 2 March 20th, 2007 12:32 PM
MS Access Query sunny76 Access 4 October 18th, 2006 06:54 AM
update query doesnt work knight Classic ASP Databases 4 June 10th, 2004 07:24 AM



All times are GMT -4. The time now is 02:00 AM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.