A Microsoft Office (Excel, Word) forum. OfficeFrustration

If this is your first visit, be sure to check out the FAQ by clicking the link above. You may have to register before you can post: click the register link above to proceed. To start viewing messages, select the forum that you want to visit from the selection below.

Go Back   Home » OfficeFrustration forum » Microsoft Access » Running & Setting Up Queries
Site Map Home Register Authors List Search Today's Posts Mark Forums Read  

Access 97 Correlated Updates



 
 
Thread Tools Display Modes
  #1  
Old November 21st, 2006, 05:18 PM posted to microsoft.public.access.queries
Roger
external usenet poster
 
Posts: 7
Default Access 97 Correlated Updates

Does anyone know how to do something like this in Access 97?

UPDATE tableB SET
date_ferment_completed =
EXISTS (
SELECT fieldID, MAX(sampleDT)
from
tableB
GROUP BY fieldID
)


I get an "Operation must use an updatable query" error.

I tried this as well


UPDATE tableB SET
date_ferment_completed =
(
SELECT MAX(sampleDT)
from
tableB
)

The inner query gets only one value for the return.

Thanks

  #2  
Old November 21st, 2006, 06:29 PM posted to microsoft.public.access.queries
dberman
external usenet poster
 
Posts: 2
Default Access 97 Correlated Updates

You want something like:

UPDATE [table1] SET [item1] = whatever
WHERE [item2] in (select [item2] from table2 where itemx like "xx*");

table1 and 2 can be the same table. The select must return the same data
type as item2 in the WHERE clause.

Good luck.
--
Don Berman
Computer Sciences Corp.


"Roger" wrote:

Does anyone know how to do something like this in Access 97?

UPDATE tableB SET
date_ferment_completed =
EXISTS (
SELECT fieldID, MAX(sampleDT)
from
tableB
GROUP BY fieldID
)


I get an "Operation must use an updatable query" error.

I tried this as well


UPDATE tableB SET
date_ferment_completed =
(
SELECT MAX(sampleDT)
from
tableB
)

The inner query gets only one value for the return.

Thanks


  #3  
Old November 21st, 2006, 06:36 PM posted to microsoft.public.access.queries
Roger
external usenet poster
 
Posts: 7
Default Access 97 Correlated Updates

Thnaks for the reply.

I am not looking for the subquery to be in the where clause.
I need it to be in the SET datecompleted = (select MAX(sampleDT) from
tableB ....

tableA
ID
datecompleted

tableB
ID
sampleDT

(TableA) (1 - Many) (TableB) relationship

so I need Max(sampleDT) in the subquery to put into date completed.

dberman wrote:
You want something like:

UPDATE [table1] SET [item1] = whatever
WHERE [item2] in (select [item2] from table2 where itemx like "xx*");

table1 and 2 can be the same table. The select must return the same data
type as item2 in the WHERE clause.

Good luck.
--
Don Berman
Computer Sciences Corp.


"Roger" wrote:

Does anyone know how to do something like this in Access 97?

UPDATE tableB SET
date_ferment_completed =
EXISTS (
SELECT fieldID, MAX(sampleDT)
from
tableB
GROUP BY fieldID
)


I get an "Operation must use an updatable query" error.

I tried this as well


UPDATE tableB SET
date_ferment_completed =
(
SELECT MAX(sampleDT)
from
tableB
)

The inner query gets only one value for the return.

Thanks



  #4  
Old November 21st, 2006, 08:14 PM posted to microsoft.public.access.queries
dberman
external usenet poster
 
Posts: 2
Default Access 97 Correlated Updates

Probably not a direct query. Chaining two queries will work.
1. Make table query
SELECT Dates.Name, Max(Dates.SubDate) AS MaxOfSubDate INTO [Dates-Max]
FROM Dates
GROUP BY Dates.Name;
2. Update query
UPDATE [Names] INNER JOIN [Dates-Max] ON Names.Name = [Dates-Max].Name SET
[Names].MaxDate = [Dates-Max].[MaxOfSubDate];

Not totally satisfactory, but will function.
--
Don Berman
Computer Sciences Corp.


"Roger" wrote:

Thnaks for the reply.

I am not looking for the subquery to be in the where clause.
I need it to be in the SET datecompleted = (select MAX(sampleDT) from
tableB ....

tableA
ID
datecompleted

tableB
ID
sampleDT

(TableA) (1 - Many) (TableB) relationship

so I need Max(sampleDT) in the subquery to put into date completed.

dberman wrote:
You want something like:

UPDATE [table1] SET [item1] = whatever
WHERE [item2] in (select [item2] from table2 where itemx like "xx*");

table1 and 2 can be the same table. The select must return the same data
type as item2 in the WHERE clause.

Good luck.
--
Don Berman
Computer Sciences Corp.


"Roger" wrote:

Does anyone know how to do something like this in Access 97?

UPDATE tableB SET
date_ferment_completed =
EXISTS (
SELECT fieldID, MAX(sampleDT)
from
tableB
GROUP BY fieldID
)


I get an "Operation must use an updatable query" error.

I tried this as well


UPDATE tableB SET
date_ferment_completed =
(
SELECT MAX(sampleDT)
from
tableB
)

The inner query gets only one value for the return.

Thanks




  #5  
Old November 21st, 2006, 08:26 PM posted to microsoft.public.access.queries
Roger
external usenet poster
 
Posts: 7
Default Access 97 Correlated Updates

Yea, that looks like the route I am going to have to take. I am
shocked that Access does not support it.

Although its microsoft.

Thanks
Roger

dberman wrote:
Probably not a direct query. Chaining two queries will work.
1. Make table query
SELECT Dates.Name, Max(Dates.SubDate) AS MaxOfSubDate INTO [Dates-Max]
FROM Dates
GROUP BY Dates.Name;
2. Update query
UPDATE [Names] INNER JOIN [Dates-Max] ON Names.Name = [Dates-Max].Name SET
[Names].MaxDate = [Dates-Max].[MaxOfSubDate];

Not totally satisfactory, but will function.
--
Don Berman
Computer Sciences Corp.


"Roger" wrote:

Thnaks for the reply.

I am not looking for the subquery to be in the where clause.
I need it to be in the SET datecompleted = (select MAX(sampleDT) from
tableB ....

tableA
ID
datecompleted

tableB
ID
sampleDT

(TableA) (1 - Many) (TableB) relationship

so I need Max(sampleDT) in the subquery to put into date completed.

dberman wrote:
You want something like:

UPDATE [table1] SET [item1] = whatever
WHERE [item2] in (select [item2] from table2 where itemx like "xx*");

table1 and 2 can be the same table. The select must return the same data
type as item2 in the WHERE clause.

Good luck.
--
Don Berman
Computer Sciences Corp.


"Roger" wrote:

Does anyone know how to do something like this in Access 97?

UPDATE tableB SET
date_ferment_completed =
EXISTS (
SELECT fieldID, MAX(sampleDT)
from
tableB
GROUP BY fieldID
)


I get an "Operation must use an updatable query" error.

I tried this as well


UPDATE tableB SET
date_ferment_completed =
(
SELECT MAX(sampleDT)
from
tableB
)

The inner query gets only one value for the return.

Thanks





  #6  
Old November 21st, 2006, 08:50 PM posted to microsoft.public.access.queries
John Spencer
external usenet poster
 
Posts: 7,815
Default Access 97 Correlated Updates

One method is to use the DMAX VBA function - can be slow.

UPDATE TableB
SET Date_Ferment_Completed = DMAX("SampleDt","TableB","FieldID =" &
TableB.FieldID)

IF FieldID is a text field then you need
UPDATE TableB
SET Date_Ferment_Completed = DMAX("SampleDt","TableB","FieldID ='" &
TableB.FieldID & "'")

"Roger" wrote in message
oups.com...
Does anyone know how to do something like this in Access 97?

UPDATE tableB SET
date_ferment_completed =
EXISTS (
SELECT fieldID, MAX(sampleDT)
from
tableB
GROUP BY fieldID
)


I get an "Operation must use an updatable query" error.

I tried this as well


UPDATE tableB SET
date_ferment_completed =
(
SELECT MAX(sampleDT)
from
tableB
)

The inner query gets only one value for the return.

Thanks



  #7  
Old November 21st, 2006, 10:46 PM posted to microsoft.public.access.queries
David F Cox
external usenet poster
 
Posts: 493
Default Access 97 Correlated Updates

UPDATE tableB ...... from tableB GROUP BY .....

you have a set of data called tableB in one state and you are trying to
change it into another set of data based on an operation upon a subset of
that data and leave the updated set of data in a known state, when changing
that data might affect the criteria. Writing the algorithms to ensure that
those conditions will be met is a major task, and it is simpler to not allow
such operations. Nothing to do with it being Microsoft.



"Roger" wrote in message
ups.com...
Yea, that looks like the route I am going to have to take. I am
shocked that Access does not support it.

Although its microsoft.

Thanks
Roger

dberman wrote:
Probably not a direct query. Chaining two queries will work.
1. Make table query
SELECT Dates.Name, Max(Dates.SubDate) AS MaxOfSubDate INTO [Dates-Max]
FROM Dates
GROUP BY Dates.Name;
2. Update query
UPDATE [Names] INNER JOIN [Dates-Max] ON Names.Name = [Dates-Max].Name
SET
[Names].MaxDate = [Dates-Max].[MaxOfSubDate];

Not totally satisfactory, but will function.
--
Don Berman
Computer Sciences Corp.


"Roger" wrote:

Thnaks for the reply.

I am not looking for the subquery to be in the where clause.
I need it to be in the SET datecompleted = (select MAX(sampleDT) from
tableB ....

tableA
ID
datecompleted

tableB
ID
sampleDT

(TableA) (1 - Many) (TableB) relationship

so I need Max(sampleDT) in the subquery to put into date completed.

dberman wrote:
You want something like:

UPDATE [table1] SET [item1] = whatever
WHERE [item2] in (select [item2] from table2 where itemx like "xx*");

table1 and 2 can be the same table. The select must return the same
data
type as item2 in the WHERE clause.

Good luck.
--
Don Berman
Computer Sciences Corp.


"Roger" wrote:

Does anyone know how to do something like this in Access 97?

UPDATE tableB SET
date_ferment_completed =
EXISTS (
SELECT fieldID, MAX(sampleDT)
from
tableB
GROUP BY fieldID
)


I get an "Operation must use an updatable query" error.

I tried this as well


UPDATE tableB SET
date_ferment_completed =
(
SELECT MAX(sampleDT)
from
tableB
)

The inner query gets only one value for the return.

Thanks








  #8  
Old November 21st, 2006, 10:58 PM posted to microsoft.public.access.queries
Roger
external usenet poster
 
Posts: 7
Default Access 97 Correlated Updates

This is a one time shot. I added a new field to the database which is
supposed to show when work is completed. For the sake of the old data,
I can take a best guess by looking at that max(date) of tableB. There
are about 10,000 records to update and I don't want to manually
transfer it. I will write a 2 step script to use the temporary table
but trying to simplify it to one sql query.

Thanks
Roger

David F Cox wrote:
UPDATE tableB ...... from tableB GROUP BY .....


you have a set of data called tableB in one state and you are trying to
change it into another set of data based on an operation upon a subset of
that data and leave the updated set of data in a known state, when changing
that data might affect the criteria. Writing the algorithms to ensure that
those conditions will be met is a major task, and it is simpler to not allow
such operations. Nothing to do with it being Microsoft.



"Roger" wrote in message
ups.com...
Yea, that looks like the route I am going to have to take. I am
shocked that Access does not support it.

Although its microsoft.

Thanks
Roger

dberman wrote:
Probably not a direct query. Chaining two queries will work.
1. Make table query
SELECT Dates.Name, Max(Dates.SubDate) AS MaxOfSubDate INTO [Dates-Max]
FROM Dates
GROUP BY Dates.Name;
2. Update query
UPDATE [Names] INNER JOIN [Dates-Max] ON Names.Name = [Dates-Max].Name
SET
[Names].MaxDate = [Dates-Max].[MaxOfSubDate];

Not totally satisfactory, but will function.
--
Don Berman
Computer Sciences Corp.


"Roger" wrote:

Thnaks for the reply.

I am not looking for the subquery to be in the where clause.
I need it to be in the SET datecompleted = (select MAX(sampleDT) from
tableB ....

tableA
ID
datecompleted

tableB
ID
sampleDT

(TableA) (1 - Many) (TableB) relationship

so I need Max(sampleDT) in the subquery to put into date completed.

dberman wrote:
You want something like:

UPDATE [table1] SET [item1] = whatever
WHERE [item2] in (select [item2] from table2 where itemx like "xx*");

table1 and 2 can be the same table. The select must return the same
data
type as item2 in the WHERE clause.

Good luck.
--
Don Berman
Computer Sciences Corp.


"Roger" wrote:

Does anyone know how to do something like this in Access 97?

UPDATE tableB SET
date_ferment_completed =
EXISTS (
SELECT fieldID, MAX(sampleDT)
from
tableB
GROUP BY fieldID
)


I get an "Operation must use an updatable query" error.

I tried this as well


UPDATE tableB SET
date_ferment_completed =
(
SELECT MAX(sampleDT)
from
tableB
)

The inner query gets only one value for the return.

Thanks







  #9  
Old November 21st, 2006, 11:08 PM posted to microsoft.public.access.queries
Roger
external usenet poster
 
Posts: 7
Default Access 97 Correlated Updates

John,

This worked, Thanks alot

Roger

Roger wrote:
This is a one time shot. I added a new field to the database which is
supposed to show when work is completed. For the sake of the old data,
I can take a best guess by looking at that max(date) of tableB. There
are about 10,000 records to update and I don't want to manually
transfer it. I will write a 2 step script to use the temporary table
but trying to simplify it to one sql query.

Thanks
Roger

David F Cox wrote:
UPDATE tableB ...... from tableB GROUP BY .....


you have a set of data called tableB in one state and you are trying to
change it into another set of data based on an operation upon a subset of
that data and leave the updated set of data in a known state, when changing
that data might affect the criteria. Writing the algorithms to ensure that
those conditions will be met is a major task, and it is simpler to not allow
such operations. Nothing to do with it being Microsoft.



"Roger" wrote in message
ups.com...
Yea, that looks like the route I am going to have to take. I am
shocked that Access does not support it.

Although its microsoft.

Thanks
Roger

dberman wrote:
Probably not a direct query. Chaining two queries will work.
1. Make table query
SELECT Dates.Name, Max(Dates.SubDate) AS MaxOfSubDate INTO [Dates-Max]
FROM Dates
GROUP BY Dates.Name;
2. Update query
UPDATE [Names] INNER JOIN [Dates-Max] ON Names.Name = [Dates-Max].Name
SET
[Names].MaxDate = [Dates-Max].[MaxOfSubDate];

Not totally satisfactory, but will function.
--
Don Berman
Computer Sciences Corp.


"Roger" wrote:

Thnaks for the reply.

I am not looking for the subquery to be in the where clause.
I need it to be in the SET datecompleted = (select MAX(sampleDT) from
tableB ....

tableA
ID
datecompleted

tableB
ID
sampleDT

(TableA) (1 - Many) (TableB) relationship

so I need Max(sampleDT) in the subquery to put into date completed.

dberman wrote:
You want something like:

UPDATE [table1] SET [item1] = whatever
WHERE [item2] in (select [item2] from table2 where itemx like "xx*");

table1 and 2 can be the same table. The select must return the same
data
type as item2 in the WHERE clause.

Good luck.
--
Don Berman
Computer Sciences Corp.


"Roger" wrote:

Does anyone know how to do something like this in Access 97?

UPDATE tableB SET
date_ferment_completed =
EXISTS (
SELECT fieldID, MAX(sampleDT)
from
tableB
GROUP BY fieldID
)


I get an "Operation must use an updatable query" error.

I tried this as well


UPDATE tableB SET
date_ferment_completed =
(
SELECT MAX(sampleDT)
from
tableB
)

The inner query gets only one value for the return.

Thanks







 




Thread Tools
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

vB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Forum Jump


All times are GMT +1. The time now is 11:12 AM.


Powered by vBulletin® Version 3.6.4
Copyright ©2000 - 2024, Jelsoft Enterprises Ltd.
Copyright ©2004-2024 OfficeFrustration.
The comments are property of their posters.