473,326 Members | 2,110 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,326 software developers and data experts.

append query to different table

jpr
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 using table1.
I type his SSN. The code should check if this SSN is already present in
another table (table2). If yes, so the code should skip the append
query and just update any modified record included the SSN.

If not, the code should run the append query.

All this should be done in the background while working in a form with
its recors source to the table1.

Can anyone help me? Thanks.

Mar 28 '06 #1
1 1862
Two thoughts:

1) If the SSN is primary/unique key in the second table, then you can
simply do the append everytime, and then run a second query to do the
update. The append will not add if the key is primary or indexed and
no duplicates allowed. And the second update will update it if perhaps
it was already there. This is a messy way but it will work.

2) Better approach:
a- perform a dlookup or dcount on the second table for a query that has
the ssn as criteria.
b- If the count is 0 then run the append query to update the file
c- if the count is >0 then run the update query to update the file.

Mar 30 '06 #2

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

Similar topics

1
by: Rose | last post by:
I have an access 2000 database. In it I have a table OPEN Items which has a field Issue that is setup as a MEMO field. I am trying to append information from another table with the same setup,...
2
by: Danny | last post by:
I want to extract a subset of fields from one table into another the master table has many fields the subset has about half, but still many. Is there a way I can just append the master into the...
1
by: David Barger | last post by:
Greetings, It appears that an Append Query I run in Access XP is randomly failing to append a field. I have payroll data being entered into a payroll database. This data is exported daily to...
2
by: Steve B | last post by:
I am trying to design a Call Log Detail form that will allow users, in a multi-user environment, to select various data/records, not necessarily in sequential order, from a subform that will, when...
1
by: travismorien | last post by:
I have four tables of different "entities". One table contains information for "people", one for "trusts", one for "companies" and one for "self managed super funds". Each type of entity has an...
4
by: MN | last post by:
I have to import a tab-delimited text file daily into Access through a macro. All of the data needs to be added to an existing table. Some of the data already exists but may be updated by the...
5
by: robertmeyer1 | last post by:
Hey, I have 2 append queries. The first is based off of code given and works great. For the second, I followed the format of the 1st and adjusted it to meet my needs. Query 1 works great. It...
0
by: Filio | last post by:
Hi all: My problem is a little different than the earlier append table post. I have T1 with an autonum field as the primary key, and T2 with identical fields as the first, but no autonum. ...
14
by: Supermansteel | last post by:
My team at work uses Cognos to run multiple queries to pull in data. Then they take that data and import into Access and then usually run an Append Query to run a RND function to pull out a few...
0
by: DolphinDB | last post by:
Tired of spending countless mintues downsampling your data? Look no further! In this article, you’ll learn how to efficiently downsample 6.48 billion high-frequency records to 61 million...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
1
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 6 Mar 2024 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, we are pleased to welcome back...
0
by: jfyes | last post by:
As a hardware engineer, after seeing that CEIWEI recently released a new tool for Modbus RTU Over TCP/UDP filtering and monitoring, I actively went to its official website to take a look. It turned...
0
by: ArrayDB | last post by:
The error message I've encountered is; ERROR:root:Error generating model response: exception: access violation writing 0x0000000000005140, which seems to be indicative of an access violation...
1
by: Defcon1945 | last post by:
I'm trying to learn Python using Pycharm but import shutil doesn't work
1
by: Shællîpôpï 09 | last post by:
If u are using a keypad phone, how do u turn on JavaScript, to access features like WhatsApp, Facebook, Instagram....
0
by: af34tf | last post by:
Hi Guys, I have a domain whose name is BytesLimited.com, and I want to sell it. Does anyone know about platforms that allow me to list my domain in auction for free. Thank you
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...

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.