Hi,
I have an append query that has to add a record to a table [Join_tbl] if the field [ReqUNID] does not exist (there are other fields added as well with their own criteria) OR If the [ReqUID] already exists but another field [TaskStatus] has changed, then overwrite the [TaskStatus] field only. This is the code I have that only adds a record if the [ReqUID] doesn't exist. - INSERT INTO Join_tbl
-
( ReqUNID,
-
TaskTeam,
-
TaskAssignee,
-
taskStatus )
-
SELECT dbo_vwAssignments.ReqUNID,
-
dbo_vwAssignments.TaskTeam,
-
dbo_vwAssignments.TaskAssignee,
-
dbo_vwAssignments.taskStatus
-
FROM dbo_vwAssignments
-
WHERE (
-
((dbo_vwAssignments.TaskTeam)
-
="chp-vm")
-
AND ((dbo_vwAssignments.taskStatus)
-
="acknowledged"
-
Or (dbo_vwAssignments.taskStatus)
-
="new"
-
Or (dbo_vwAssignments.taskStatus)
-
="pending"
-
Or (dbo_vwAssignments.taskStatus) Is Null));
Thank you in advance for your help
7 3932
You will need two querys. An append query and an update query. I don't think you can do it with just one query in Access.
thank you, i did get to that point after i asked for help. You are quick, (Rabbit). I built the queries but for some reason my update query makes the data in the field to be updated blank. This is my update query: - UPDATE Temp_Join_tbl
-
INNER JOIN Join_tbl
-
ON Temp_Join_tbl.ReqUNID
-
= Join_tbl.ReqUNID
-
SET Join_tbl.ReqUNID
-
= [Temp_Join_tbl].[ReqUNID],
-
Join_tbl.Status
-
= [Temp_Join_tbl].[Status]
-
WHERE (
-
((Join_tbl.ReqUNID)
-
=[Join_tbl].[ReqUNID])
-
);
I'm trying to update the Join_tbl.[status] with the value in Temp_Join_tbl.[Status] WHERE Temp_Join_tbl.ReqUNID = Join_tbl.ReqUNID SET Join_tbl.ReqUNID
Any suggestion?
sorry, i since removed the ReqUID field from the query and it works fine, but I don't understand why.
NeoPa 32,556
Expert Mod 16PB Rabbit:
You will need two querys. An append query and an update query. I don't think you can do it with just one query in Access.
Until quite recently I would have agreed with that. It turns out however, that an UPDATE query will act as an APPEND query in Access (Jet) when no match existing record is found.
NeoPa 32,556
Expert Mod 16PB Robin:
sorry, i since removed the ReqUID field from the query and it works fine, but I don't understand why.
If you were trying to set an AutoNumber value from another table then it would fail. AutoNumber values can only ever be set explicitly within an APPEND action. When you removed the code to set that the query could work.
zmbd 5,501
Expert Mod 4TB
Post #3 Codeblock-Line 10: The WHERE clause with the SQL refers to the same table and same field; However, this is not as indicated in the sentence following wherein that statement refers to the fields between the two tables.
If the [ReqUID] is an autonumber it should have erred, not cleared fields.
NeoPa 32,556
Expert Mod 16PB Z:
If the [ReqUID] is an autonumber it should have erred, not cleared fields.
Good spot. I didn't see (overlooked) that detail :-(
So was the spot of the error in the OP's WHERE clause. Sharp today Z :-)
Sign in to post your reply or Sign up for a free account.
Similar topics
by: |
last post by:
I found similiar issues in MS-KB but nothing that helped
me; got the Windows and Office updates from the MS website
but that hasn't changed the behavior of this problem, and
I don't see anything...
|
by: Ray Holtz |
last post by:
I have a form that shows a single record based on a query criteria.
When I click a button it is set to use an append query to copy that
record to a separate table, then deletes the record from the...
|
by: jpr |
last post by:
Friends, I would like some help with a code that allows me to run an
append query only if a specific field is not already stored into
another table.
Example.
I add a new customer to my database...
|
by: pmacdiddie |
last post by:
I have an append query that needs to run every time a line item is
added to a subform. The append writes to a table that is the source
for a pull down box. Problem is that it takes 5 seconds to...
|
by: jon |
last post by:
Hi there,
I'm brand new to Access and may be trying to do too much too soon, but
I wanted to get some expert advice on how the best way to go about what
I am trying to accomplish would be.
I...
|
by: kabradley |
last post by:
Hello Everyone,
So, thanks to nico's help I was finally able to 'finish' our companies access database. For the past week or so though,I have been designing forms that contain a subform and an...
|
by: Sailor7 |
last post by:
The problem I am having is setting up some code to query a table(Tbl_Table1_ContainsLotsOfData)
using criteria in another table(Tbl_Table2_ContainsCriteria),
then appending the result to an...
|
by: ilikebirds |
last post by:
In 1 Database(ttt) I currently have a Union Query that collects data from 4 databases (a,b,c,d) and then a MakeTable query that combines all of those into a table. ( Union A,B,C,D to make table in...
|
by: brandon Gadish |
last post by:
I am trying to append a table with records from another table. When I run the Append query the first time it works fine, however when I run it a second time it will duplicate the records. I created...
|
by: Adam Tippelt |
last post by:
Situation:
When a user 'confirms' that they want to save the information they've inputted, I need to append the database records from a temporary table to a different table.
Problem:
The...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: BarryA |
last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
|
by: Hystou |
last post by:
There are some requirements for setting up RAID:
1. The motherboard and BIOS support RAID configuration.
2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
|
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...
|
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...
|
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...
|
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,...
|
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...
| |