473,491 Members | 2,221 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

automatically update fields in a table using values within the same table

I have a table that is shown below in ORIGINAL TABLE. It is common for
the VEHICLE # field to have repeating vehicles (ID 3,4,5 & 8,9).
Usually the Vehicle will have SHIPDATE, DATE_RECEIVED, and
DATE_ORDERED for the first entry, after that is could be null (ID 4 &
5). What I would like to do is for a query or VB code to look into the
ORIGINAL TABLE, find the duplicating VEHICLES. Where ever
DATE_RECEIVED or DATE_ORDERED is empty, automatically update it using
DATE_RECEIVED and DATE_ORDERED from the previous entry of the same
vehicle( but SHIPDATE MUST BE THE SAME!!).

ORIGINAL TABLE
ID VEHICLE # SHIPDATE DATE_RECEIVED DATE_ORDERED
1 BF16 5/1/2004 4/30/2004 4/28/2004
2 BF22 5/4/2004 5/1/2004 4/31/2004
3 GT15 5/15/2004 5/10/2004 5/9/2004
4 GT15 5/15/2004
5 GT15 5/15/2004
6 RV66 5/19/2004 5/18/2004 5/17/2004
7 RV68 5/19/2004 5/18/2004 5/17/2004
8 JM40 5/20/2004 5/18/2004 5/16/2004
9 JM40 5/22/2004
10 BX12 5/29/2004 5/25/2004 5/20/2004

RESULTING TABLE
ID VEHICLE # SHIPDATE DATE_RECEIVED DATE_ORDERED
1 BF16 5/1/2004 4/30/2004 4/28/2004
2 BF22 5/4/2004 5/1/2004 4/31/2004
3 GT15 5/15/2004 5/10/2004 5/9/2004
4 GT15 5/15/2004 5/10/2004 5/9/2004
5 GT15 5/15/2004 5/10/2004 5/9/2004
6 RV66 5/19/2004 5/18/2004 5/17/2004
7 RV68 5/19/2004 5/18/2004 5/17/2004
8 JM40 5/20/2004 5/18/2004 5/16/2004
9 JM40 5/22/2004
10 BX12 5/29/2004 5/25/2004 5/20/2004

Here, DATE_RECEIVED & DATE_ORDERED in rows ID 4,5 have been
automatically updated using values from row ID 3. Row ID 9 did not get
updated with using ID 8 because they have different SHIPDATE.

Any help is greatly appreciated. I cannot find a way to solve this at
all.

JIm
Nov 13 '05 #1
1 1850
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Untested query:

UPDATE [Original Table] As A LEFT JOIN [Original Table] As B
ON A.[Vehicle #] = B.[Vehicle #] AND A.[ShipDate] = B.[ShipDate]
SET B.Date_Received = A.Date_Received,
B.Date_Ordered = A.Date_Ordered
WHERE A.Date_Received IS NOT NULL
AND A.Date_Ordered IS NOT NULL

--
MGFoster:::mgf00 <at> earthlink <decimal-point> net
Oakland, CA (USA)

-----BEGIN PGP SIGNATURE-----
Version: PGP for Personal Privacy 5.0
Charset: noconv

iQA/AwUBQUhvyYechKqOuFEgEQK/8gCg2qoWRj3ZWYQhNMcwpdt8aS7oZMsAoKg4
ACtzwAVZxOhF6GQo69TtM/U9
=awQD
-----END PGP SIGNATURE-----
Jimmy wrote:
I have a table that is shown below in ORIGINAL TABLE. It is common for
the VEHICLE # field to have repeating vehicles (ID 3,4,5 & 8,9).
Usually the Vehicle will have SHIPDATE, DATE_RECEIVED, and
DATE_ORDERED for the first entry, after that is could be null (ID 4 &
5). What I would like to do is for a query or VB code to look into the
ORIGINAL TABLE, find the duplicating VEHICLES. Where ever
DATE_RECEIVED or DATE_ORDERED is empty, automatically update it using
DATE_RECEIVED and DATE_ORDERED from the previous entry of the same
vehicle( but SHIPDATE MUST BE THE SAME!!).

ORIGINAL TABLE
ID VEHICLE # SHIPDATE DATE_RECEIVED DATE_ORDERED
1 BF16 5/1/2004 4/30/2004 4/28/2004
2 BF22 5/4/2004 5/1/2004 4/31/2004
3 GT15 5/15/2004 5/10/2004 5/9/2004
4 GT15 5/15/2004
5 GT15 5/15/2004
6 RV66 5/19/2004 5/18/2004 5/17/2004
7 RV68 5/19/2004 5/18/2004 5/17/2004
8 JM40 5/20/2004 5/18/2004 5/16/2004
9 JM40 5/22/2004
10 BX12 5/29/2004 5/25/2004 5/20/2004

RESULTING TABLE
ID VEHICLE # SHIPDATE DATE_RECEIVED DATE_ORDERED
1 BF16 5/1/2004 4/30/2004 4/28/2004
2 BF22 5/4/2004 5/1/2004 4/31/2004
3 GT15 5/15/2004 5/10/2004 5/9/2004
4 GT15 5/15/2004 5/10/2004 5/9/2004
5 GT15 5/15/2004 5/10/2004 5/9/2004
6 RV66 5/19/2004 5/18/2004 5/17/2004
7 RV68 5/19/2004 5/18/2004 5/17/2004
8 JM40 5/20/2004 5/18/2004 5/16/2004
9 JM40 5/22/2004
10 BX12 5/29/2004 5/25/2004 5/20/2004

Here, DATE_RECEIVED & DATE_ORDERED in rows ID 4,5 have been
automatically updated using values from row ID 3. Row ID 9 did not get
updated with using ID 8 because they have different SHIPDATE.


Nov 13 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
8318
by: Jason | last post by:
I need to populate a table from several sources of raw data. For a given security (stock) it is possible to only receive PARTS of information from each of the different sources. It is also...
7
2969
by: Philip Mette | last post by:
I have been searching many postings and I cant seem to find anyone that has this answer so I decided to post. I am using SQL (Transact-SQL).If I have 2 tables with columns...
4
1855
by: jean.ockert | last post by:
Greetings. Access version 2003 on an XP system I am using the template "Event Management" database as the primary database and need additional functionality added. I have a dance studio. ...
1
1875
by: keliie | last post by:
I have a relatively simple (I assume) issue which I am at a complete loss to address. My issues is: I want to populate fields in my tables with summary data from the same table. Let me explain: ...
0
1640
by: khoegen | last post by:
Folks, I am in the process of designing a database, within which I have created a table called "tblDOCUMENTS". As the title suggests, this is a list of documents (records) of varying types. I...
3
1801
by: Birky | last post by:
Do to multiple iterations of data contained in my Event_Log table I now find myself having to update all entries within my Element_Name column that are = “ “ to a Null value. This is necessary for...
1
1680
by: lunas | last post by:
hi i have to update a table based on a criteria with value selected from another table. i am writting a java progg for it . i just want to know can it be done with one statement. my purpose is ...
2
1866
by: obs | last post by:
Hi all. I have two tables: Pages consists of an id field: PageId, and some other fields NewsTemplate consists of another id field: PageId , and some other fields I want to update PageId in...
3
19213
by: fionashaw | last post by:
I am trying to fix an issue for a customer which requires us to update a column in a table with the value in the column concatenated (||) with the value in another row in the same table. The table...
0
7190
jinu1996
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...
1
6858
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
7360
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
1
4881
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4578
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3086
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
1392
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...
1
633
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
0
280
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.