473,765 Members | 1,964 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Referring to last date in table01 to run a query on table02

Hi there,

I have 2 tables, one with data in it, where each record has
a date, this table being table01. I want to apend data to
this table, but from Tabl02, but only new data, so
essentially append to table01 from table02 where dateField
in Table02 is greater than dateField in table01...

Hope someone is able to help, I have searched MS access
2000 help thouroughly, but haven't been able to find
anything helpful.

thx,
Nov 12 '05 #1
2 1666
This was interesting to work on.

This query does the job:
INSERT INTO table01 ( dateField, textField )
SELECT table02.dateFie ld, table02.textFie ld
FROM table02
WHERE (((table02.date Field)>DMax("[table01].[datefield]","[table01]")));

You must have at least one record in table01 with a date in it for this
to work.

I assumed that you want to append table02 records where that date is >
the most recent (maximum) date in table 01. You didn't indicate that
you're comparing a particular record in table02 to a particular record
in table01 - so I went for the max date in table 02.

I used DMax("[table01].[datefield]","[table01]") to get that maximum date.

I built a table01 and table02. Each has a fieldDate and fieldText, and
also a fieldAutoNum that is effectively irrelevant to this task.

If you're not used to working with straight SQL in Access - -
Create a new query, but add no tables or anything.
Click View - SQL. Paste in the SQL from above.
Go back to design view if you like.
Of course you need to add any other fields you have that need to be
"copied" to your table01.
Don't try to copy data from an AutoNum field as table01 will maintain
its own AutoNum field if it has one.
To see where the destination table is specified, click Query - Append.
To run it from design view, click Query-run, or click the big red ! on
the toolbar.
(I had to write that, since it's a real drag if you don't know where to
run it from.)

Bruce Pick

du**@coolgroups .com wrote:
Hi there,

I have 2 tables, one with data in it, where each record has
a date, this table being table01. I want to apend data to
this table, but from Tabl02, but only new data, so
essentially append to table01 from table02 where dateField
in Table02 is greater than dateField in table01...

Hope someone is able to help, I have searched MS access
2000 help thouroughly, but haven't been able to find
anything helpful.

thx,

Nov 12 '05 #2
Possibly an easier way is to have a boolean field "blnExporte d" in
table02 that has a default of No.

You build an Append query that appends WHERE blnExported=No.
Immediately after running it, you run an update query that sets all
those blnExported fields in Table02 to Yes. You don't need to export
the boolean field to table01, and you don't need to track dates if you
don't need them for other purposes.

That method might run more quickly if you eventually end up with lots of
records for it to test.

Bruce Pick

du**@coolgroups .com wrote:
Hi there,

I have 2 tables, one with data in it, where each record has
a date, this table being table01. I want to apend data to
this table, but from Tabl02, but only new data, so
essentially append to table01 from table02 where dateField
in Table02 is greater than dateField in table01...

Hope someone is able to help, I have searched MS access
2000 help thouroughly, but haven't been able to find
anything helpful.

thx,

Nov 12 '05 #3

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

Similar topics

3
2021
by: AndyBell | last post by:
Hi all! I have an Access 2000 database for the Habiat for Humanity where I work. This is the second database I have written and it gets a bit more complex each time... I have learned much and read much over the last few months and have found leads to the answers to several other problems I have encountered with a Google search of past posts/threads. SO thank you for the help already rendered even though you didn't know!! My problem...
3
6619
by: Melissa | last post by:
I have this table: TblProjectYear ProjectYearID ProjectYearStartDate ProjectYearEndDate The Project Year will always span across December 31; for example 9/1/04 to 6/30/05. How do I build a combobox based on this table that will display all the months between the StartDate and the EndDate for a given ProjectYearID and when a selection is made, the full date of the last day of the selected
1
2222
by: samotek | last post by:
Filter the last date only I am trying t0 filter only the last date of the query,but i cannot manage that. My query is the following : SELECT Sum(.liters) AS SumOfLiters, orders.invoicedate FROM orders LEFT JOIN ON orders.orderid = .OrderID GROUP BY orders.invoicedate;
2
1870
by: solar | last post by:
I have a problem with building a totals query showing data for the last date only.Under the last date i understand the last date of field invoicedate.This invoice date is in the table orders. Therefore in the column of the query i have entered : DMax("InvoiceDate";"Orders") I have also tried with : DayNumber: DatePart('d';)
9
16932
by: ice | last post by:
Hello, I have a couple of tables. The client tables and the contacted tables. I am not sure how to start on this, what I need is a way to query all my clients then show any client that the last visit and or called day is greater than 30 days. Now it gets confusing, Suppose the client was visited more than 30 days ago but was called only 10 days ago, I really would like to have this
2
4234
by: dauwe.peter | last post by:
A table : Nameperson, Book nr, Bookdatein, Bookdateout, CD nr, cddatein, cddateout, dvd nr, dvddatein, dvddateout. I would like a query where a see the personsname en de last book with the datein and out , the last cd with datein and out , and the same for the dvd. Because the last time the person came he toke only a book but dit not return his dvd (for example). But with one click i would like to see the last of every item with the...
3
6361
by: paii, Ron | last post by:
I have a sales table that logs sales information for each active job at the end of each month. My question is, will the following query give me the last sell price for each job in the sales table? SELECT DISTINCTROW tblJobSales.Job, Last(tblJobSales.SellPrice) AS SellPrice FROM tblJobSales WHERE (((tblJobSales.SellDate) Between #1/1/2007# And #12/31/2007#)) GROUP BY tblJobSales.Job; I have been using Max(tblJobSales.SellPrice), but I...
2
7641
oszapped
by: oszapped | last post by:
I am new to creating SQL queries and need some help. I am trying to query from three tables. 1 - A table with a list of Drawings (DRAWINGS) 2 - A table with the Revision history of the Drawings (REVISIONS) 3 - A table with the list of Projects (WRI_SITE_PRJS) The result I am looking for: Name of Drawing (I want to return the drawings that don't have a revision as well) Last Drawing Revision
2
3104
by: scott | last post by:
Hi Everyone, I have a table which has many fields in it but I need to pull some specific info via a query and I don't know if it's possible. I want to run a query which includes two tables. Participants and Payments. They are linked so that a participant can make many payments and a report can then be printed on all payments that participant has made. What I want to do is have a field in the payments table that has a "PaidTo"
0
9568
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9399
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10161
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
1
9955
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8831
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
7378
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5275
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 last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
2
3531
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
3
2806
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 can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.