Query to populate a field in an exists table

Richard-B

New member
Local time
Today, 05:46
Joined
Dec 28, 2021
Messages
4
I have a table containing 1.6 million reacts.
I want to take the date in the table and populate another field in the same table.
The table is index.
I was going to use an append query but I can not get it working

This is what I want to do.
Date field example 12/10/2021 = DayMonth field 12/10

1641508526945.png
 
Hi. Welcome to AWF!

Have you tried using a Calculated Column?
 
use query and add a Calculated column.
the query is more versatile and you don't need
to do an Update everytime there is new Date or new record
being added.
 
To your question, you should not use an APPEND query but a SELECT query to calculate the total. Then in that SELECT query you would use the Day() and Month() functions:



Additionally, you have some bad names for fields:

1. Spaces should not be in names. Makes coding and querying harder. Instead use an underscore: [Obs N] -> [Obs_N], [Site quoted] -> [Site_quoted]

2. Don't use reserve words as names. [Date] should not be a field name because its a built in function name. Instead name it for what that date represents (e.g. SurveyDate). You can find of all reserved words here:

 
Just a little more clarification.
Append queries add NEW rows
Update queries update EXISTING rows.

Your question is about populating an empty column.
1. the query itself cannot add a new column to a table so you would need to do that manually and first.
2. you would need to use an update query to update the new column with calculated data from a different column.

Do NOT take that explanation as support for your "solution". The others are correct. It is far better to create a calculate column in the query than to save calculated data. There are cases that can justify saving a calculated value but this is not one of them.
 

Users who are viewing this thread

Back
Top Bottom