473,406 Members | 2,843 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,406 software developers and data experts.

Appending Unique Records Please Help

I have two tables. 1 table called T_AddressHistory (Historic Data) and the other called T_Customers (Live Editable Table)

I want to append the new changes made to a the T_customers table into the T_AddressHistory.

The fields in question are CustomerID, Add1 and Postcode.

Example 1

CustomerID = 100001
Add1 = 25 Hope Street
Postcode = SE23 1HX

The above data now resides in the T_AddressHistory.

If the add1 and postcode fields were edited in the T_Customer 100001 record then i am hoping that the next time I run the query it will append a new record of

Example 2

CustomerID = 100001
Add1 = 11 Main Barn
Postcode = LL44 1HX

I am currently getting around this by creating a query via joining both tables together via the Customerid. Then under the Add1 and Postcode criteria I am enterting the "not like".. statement. Then to prevent duplicate records being added I have had to add Primary Keys on the CustomerId, Add1 and the Postcode of the T_addressHistory table. I know there must be a more correct manner of doing this query and would really appreciate your help.
Thank you.
Sep 27 '07 #1
8 2387
Scott Price
1,384 Expert 1GB
Well, first of all, why two tables?

Can you not just leave the data in the same table if it's being updated? Or are you trying to track the changes made by customer/address?

There is a rather neat way to check for a particular record using a recordset that might be useful to you if you MUST have the two tables...

It involves passing a parameter (probably customerID in your case) into a public function that opens the recordset, sets which index to use and then seeks for the parameter. You could re-write this to append the records, or call it from an If ---Then statement (as it's currently written it returns a boolean value), or even call it from a query if you could figure out what value you want it to pass to the query.

Let me know first of all if having two tables is required (which violates several db design rules) and second of all if you want to take a look at this recordset function.

Regards,
Scott
Sep 28 '07 #2
Hi Scott.
Thanks for your reply.
I have made two tables because I want to keep track of the changes a customer has made to their address. I currently run this query on a daily basis and also append the date/time.
With regards to your recordset procedure, its sounds like what I need but is it difficult to program? I am no expert in writing code as Access 97 is new to me, but if you can provide the code for me to make a module or the gudelines to make it in a design view query that would be much appreciated.
Thanks once again and look forward to hearing from you.

Regards.

Michael
Sep 28 '07 #3
Scott Price
1,384 Expert 1GB
Hi Scott.
Thanks for your reply.
I have made two tables because I want to keep track of the changes a customer has made to their address. I currently run this query on a daily basis and also append the date/time.
With regards to your recordset procedure, its sounds like what I need but is it difficult to program? I am no expert in writing code as Access 97 is new to me, but if you can provide the code for me to make a module or the gudelines to make it in a design view query that would be much appreciated.
Thanks once again and look forward to hearing from you.

Regards.

Michael
Hmmm... Access 97? I may have to back up on this one. I'm working with Access 2003, and there are a number of features that aren't exactly the same. Is your setup working for you now?

Let me think about this a bit, I'll be away for the weekend, but will be back Sunday evening.

Regards,
Scott
Sep 28 '07 #4
mlcampeau
296 Expert 100+
Instead of 2 tables, you could always just have the one, with an extra field named Active with a datatype of Yes/No. Then when there is an address change, you can add the new address to the table and just make the new one active, and the old one inactive.
Sep 28 '07 #5
FishVal
2,653 Expert 2GB
Hi, Michael.

You may not store Address info in [T_customers] table at all. Just retrieve latest customer address added to [T_addressHistory] table. Or add to [T_customers] table field [CurrentAddress] which is FK of table [T_addressHistory] PK. With this configuration you may just add multifield index to [T_addressHistory] avoiding duplicates.
Sep 28 '07 #6
Hi Thank you everyone for your replys. I was unable to answer earlier as I have been experiencing some DSL problems!.

To Scott.

We are currently using a program that was written many years ago with the back end database built in access 97. We can not upgrade this back end database to Access 2002 or 2003 because when we tried it caused all sort of bugs in the front end mde user interface. Even the original developers no longer support it. As I also have access 2003, an idea may be to create a new database in access 2003 and link to the backend tables that are in access 97. I can do all the querying and modules in access 2003 that you want me to do but any changes required will be made to the linked table that is within the Access 97 database. What do you think? Will this work and do you think I can come across any possible errors?

Thanks Scott and look forward to hearing from you.

To Fishval,

Unsure of your statement. We currently already use an access 97 built program, whenever an operator makes changes to an address of a customerID it does not store the previous address details at hand. I was hoping on running a query directly to the backend database on a regular basis into a new table I have created so that I can store customer’s previous address details.
Oct 5 '07 #7
FishVal
2,653 Expert 2GB
Hi, Michael.

[T_customers] table and [T_addressHistory] table are in classical 1-many relationship. So what is the reason to store address in [T_Customers].
There are two options of recognizing relevant address:
  • the latest added is relevant
  • explicitly store relevant address FK in [T_Customers] table
Simple tabble join will give you records with customer info including relevant address.

And again, with this configuration you may just add multifield index to [T_addressHistory] avoiding duplicates.

Does this make a sense?

Regards,
Fish
Oct 9 '07 #8
Scott Price
1,384 Expert 1GB
Hi Michael,

I would suggest migrating to a newer version of Access, A2003 is probably the best one at the moment.

As far as the possible errors you will/may encounter in the upgrade, I can't, unfortunately, foresee what all you might run into. However, if you do like you are mentioning and re-build the front-end with A2003 while leaving the back-end either in A97 format, or (better) converting it to A2000 format, you shouldn't run into anything insurmountable.

The suggestion FishVal made is a good one, and should get some serious consideration. It would require separating the address information from your Customers table, and leave it completely in the Address information table. This would require adding a separate field in the Address table to indicate which address is the current one. Here you might take a good look at Michelle's suggestion of putting a field named Active Yes/No data type in the Address table. Then the change to indicate a new address is as simple as adding the new, with Yes in this field, and changing the old to No.

Any other problems you run into during the upgrade process, we'll be glad to take a stab at helping you out!

Regards,
Scott
Oct 12 '07 #9

Sign in to post your reply or Sign up for a free account.

Similar topics

9
by: paul | last post by:
Hiya everyone, I have two tables in SQL 2000. I would like to append the contents of TableA to TableB. Table A has around 1.1 Million Records. Table B has around 1 Million Reocords. ...
7
by: Nicolae Fieraru | last post by:
I have two tables, they contain: Table1: ID1, Name1, Address1, Purchase1 Table2: ID2, Name2, Address2, Purchase2 I need a query which creates Table3 with content from Table1 and Table2. The...
3
by: kylei | last post by:
When I try to append one table to another with the exact same field names I get an error... Microsoft Access was unable to append all the data to the table. The contents of fields in 0...
3
by: MLH | last post by:
I have a query, qryAppend30DayOld260ies that attempts to append records to tblCorrespondence. When run, it can result in any of the following: appending no records, appending 1 record or appending...
7
by: PC Datasheet | last post by:
Looking for suggestions ---- A database was designed for a national automobile inspection program. In it's simplest form, the database has two tables: TblOwner OwnerID <Year/Make/Model owned...
6
by: deejayquai | last post by:
Hi I'm still trying to solve my problem. I have two tables- students and activity assessments, they're linked one-to-many. From a lookup/combo/list I'd like to be able create a series of new...
13
by: Shwetabh | last post by:
Hi, I wanted to know if it is possible to do to append two tables into a third table. For example, consider these two tables Table 1...
4
by: BA | last post by:
Hello, I have a very strange code behavior that I cannot make heads or tails of: I have c# code being executed in BizTalk assemblies which is acting very strangely. In my BizTalk process I...
2
by: srusskinyon | last post by:
I need some help getting unique records from our database! I work for a small non-profit homeless shelter. We keep track of guest information as well as what services we have offered for...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
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...
0
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,...
0
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...
0
jinu1996
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...
0
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...
0
tracyyun
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...
0
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,...
0
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...

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.