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  

Update Query



 
 
Thread Tools Display Modes
  #1  
Old March 22nd, 2010, 07:10 AM posted to microsoft.public.access.queries
Access Rookie[_3_]
external usenet poster
 
Posts: 6
Default Update Query

How do I create an update query to automatically assign the create date of
9/24/2009 as the end date for for the record with the create date of 9/15/09.

ID CATEGORY DURATION CREATE_DATE END_DATE
2381 Service 13 - 24 months 9/15/2009 9:35:00 AM
2381 Service 13 - 24 months 9/24/2009 12:41:00 PM

  #2  
Old March 22nd, 2010, 12:24 PM posted to microsoft.public.access.queries
John Spencer
external usenet poster
 
Posts: 7,815
Default Update Query

The SQL for what you asked would look like the following.

UPDATE SomeTable
Set End_Date = #2009-09-24#
WHERE Create_Date =#2009-09-15# and Create_Date #2009-09-16#
AND End_Date is Null

However, what I think you are asking is how to do this for a group of records
where End_Date is Null

UPDATE SomeTable
SET End_Date = DMin("Create_Date","SomeTable", "ID=" & ID & " AND
Create_Date" & Format(Create_Date,"\#yyyy-mm-dd\#"))
WHERE End_Date is Null

In query design view
== add your table
== add the end_date field
== set the criteria to Is Null
== Select Query Update
== Enter the following (adjust for your table name) into the update to
DMin("Create_Date","[SomeTable]", "ID=" & ID & " AND Create_Date " &
Format(Create_Date,"\#yyyy-mm-dd\#"))

John Spencer
Access MVP 2002-2005, 2007-2010
The Hilltop Institute
University of Maryland Baltimore County

Access Rookie wrote:
How do I create an update query to automatically assign the create date of
9/24/2009 as the end date for for the record with the create date of 9/15/09.

ID CATEGORY DURATION CREATE_DATE END_DATE
2381 Service 13 - 24 months 9/15/2009 9:35:00 AM
2381 Service 13 - 24 months 9/24/2009 12:41:00 PM

 




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 07:35 PM.


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