Query to populate a field in an exists table (1 Viewer)

Richard-B

New member
Local time
Today, 10:57
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
 

theDBguy

I’m here to help
Staff member
Local time
Today, 02:57
Joined
Oct 29, 2018
Messages
21,473
Hi. Welcome to AWF!

Have you tried using a Calculated Column?
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 17:57
Joined
May 7, 2009
Messages
19,243
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.
 

plog

Banishment Pending
Local time
Today, 04:57
Joined
May 11, 2011
Messages
11,646
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:

 

Pat Hartman

Super Moderator
Staff member
Local time
Today, 05:57
Joined
Feb 19, 2002
Messages
43,275
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

Top Bottom