My Query looks like this and Access complains it is wrong.
UPDATE top 7 tDelivered SET wanted = true where wanted = false
Thanks.
Access knows UPDATE but unlike with SELECT you can not use the
predicate TOP.
Note also that your statement is at least ambiguous.
Do you want to update the top 7 records (but only records with the
value false) or do you want to update the top 7 of records with the
value (in this case you will always update 7 records)? I assume the
first.
You may create two queries. The first (Q1) to select records:
SELECT TOP 7 Wanted FROM tDelivered
The second to update:
UPDATE Q1 SET Wanted=True WHERE Wanted= False
Groeten,
UPDATE tDelivered
SET Wanted = True
WHERE tDelivered.PrimaryKey IN
(SELECT TOP 7 PrimaryKey
FROM tDelivered
WHERE Wanted = False)
Since I don't know exactly what you are attempting to do I can't say that the
above will do what you wish.
John Spencer
Access MVP 2002-2005, 2007-2010
The Hilltop Institute
University of Maryland Baltimore County
--
Duane Hookom
Microsoft Access MVP
"John Spencer" wrote:
> .
>
John Spencer
Access MVP 2002-2005, 2007-2010
The Hilltop Institute
University of Maryland Baltimore County
Looks like putting order by is a good idea to avoid possible starvation in
the long run. But even I put Order by, the query still doesn't work in
Access 2007. The software complains that Syntax Error in Update.
Update top 7 tDelivered SET wanted = true where wanted = false order by
Ddate
"John Spencer" <spe...@chpdm.edu> 在郵件
news:uyGteluj...@TK2MSFTNGP02.phx.gbl 中撰寫...
Thank you John.
"John Spencer" <spe...@chpdm.edu> 在郵件
news:O0Tnvctj...@TK2MSFTNGP04.phx.gbl 中撰寫...
with savedQuery:
SELECT TOP 7 ...
would also do the job.
Vanderghast, Access MVP
"Aldred@office" <aldred> wrote in message
news:3C33B2FC-08EA-4AB0...@microsoft.com...
"vanderghast" <vanderghast@com> 嚙箭嚙締嚙踝蕭
news:C3786A3E-FC50-4733...@microsoft.com 嚙踝蕭嚙踝蕭嚙篇...
>This is a stored procedure in Access?
>
>"vanderghast" <vanderghast@com> ?b?l??
>news:C3786A3E-FC50-4733...@microsoft.com ?????g...
>> UPDATE savedQuery SET wanted=true WHERE wanted = false
No, Access does not have Stored Procedures (unlike SQL/Server); this is the
SQL view of a Query.
--
John W. Vinson [MVP]
If you create them with DDL using ADO or SQL 92 mode in Access, they
are called procedures. And if you think about it, outside of Access,
it really works out like this:
Access SELECT/CROSSTAB query = SELECT statement = VIEW
Access Action Query = INSERT/DELETE/UPDATE statement =
SPROC
Now, a stored procedure in a server database can do a lot more than
just contain a DDL statement, but on a server database, persistent
DDL statements are stored as stored procedures.
--
David W. Fenton http://www.dfenton.com/
usenet at dfenton dot com http://www.dfenton.com/DFA/