473,609 Members | 1,868 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

consolidating tables

I've used Access pretty basically for the last couple of years, and I'm
slowly trying to get a bit more advanced.
I'm attempting to consolidate multiple tables with similar information.
Some tables might have an extra column, but for the most part these
fields are similar (data within fileds is unique, at least somewhat
unique).
What is the best way to get the headers all populated and to fill the
data fields accordingly. For example, let's say my largest column set
is 30 fields, however some of my tables have only 20 or 25 fields of
that same header. I don't want to lose any header information, and i
want the data to fill whatever column it fillls in the individual
tables i've created. How can i consolidate these tables together??
I'm attempting to consolidating anywhere from 10 -20 seperate tables at
a time into one large "historical file". I thought this could be done
easily as i remember having this issue a while back. However it has
been some time since i've dealt with Access at this level. Any help
would be appreciated. Thanks...

May 12 '06 #1
1 2616
DFS
Monkey Boy wrote:
I've used Access pretty basically for the last couple of years, and
I'm slowly trying to get a bit more advanced.
I'm attempting to consolidate multiple tables with similar
information. Some tables might have an extra column, but for the
most part these fields are similar (data within fileds is unique, at
least somewhat unique).
What is the best way to get the headers all populated and to fill the
data fields accordingly. For example, let's say my largest column set
is 30 fields, however some of my tables have only 20 or 25 fields of
that same header. I don't want to lose any header information, and i
want the data to fill whatever column it fillls in the individual
tables i've created. How can i consolidate these tables together??
I'm attempting to consolidating anywhere from 10 -20 seperate tables
at a time into one large "historical file". I thought this could be
done easily as i remember having this issue a while back. However it
has been some time since i've dealt with Access at this level. Any
help would be appreciated. Thanks...

Your name's funny. I used to make fun of my best friend, who was really
hairy, by calling him Monkey Boy - he hated it.

1) First step is cleaning the tables and data a bit. Pick through all your
tables and standardize the column names (if one table has CustID and the
other has CustomerID, choose one and use it everywhere). Same with column
datatypes (if CustID is datatype Text in one table and datatype Number in
another, choose one and use it everywhere). A byproduct of this is you will
probably end up cleaning the data a bit as well. That's a good thing.

2) Build your new "historical " table into which all the other data will go.
It must have every field found in all the other tables, and it should match
the data types you end up with after the cleaning process in step 1.

3) Make a copy of the database, and do the following in the copy until we
get it to work. Then do it in the master.

4) Create a new module, and paste the following code

Public Function getFieldNames(t blName As String) As String

'BUILDS A STRING CONTAINING ALL THE FIELDS IN A TABLE
getFieldNames = ""

Dim db as database, rsG As Recordset, k As Byte
set db = currentdb()

Set rsG = db.OpenRecordse t("SELECT TOP 1 * FROM [" & tblName & "];", ,
dbOpenSnapshot)
For k = 0 To rsG.Fields.Coun t - 1
getFieldNames = getFieldNames & "[" & rsG(k).Name & "], "
Next k
rsG.Close
Set rsG = Nothing

getFieldNames = Left(Trim(getFi eldNames), Len(Trim(getFie ldNames)) - 1)

End Function

Public Sub appendHistory()

Dim db As Database, cSQL As String, tblName As String
Dim response As Byte, i As Byte

Set db = CurrentDb()

db.execute("DEL ETE FROM [HISTORICAL];")

For i = 0 To db.TableDefs.Co unt - 1
If db.TableDefs(i) .Name <> "HISTORICAL " Then

tblName = db.TableDefs(i) .Name
response = MsgBox("Append data from " & tblName & "?", vbYesNo,
"Build History")

If response = vbYes Then
cSQL = "INSERT INTO [HISTORICAL] (" & getFieldNames(t blName)
& ") "
cSQL = cSQL & "SELECT " & getFieldNames(t blName) & " "
cSQL = cSQL & "FROM [" & tblName & "] "
db.Execute (cSQL)
End If

End If
Next i
MsgBox "Finished"

End Sub
5) I named your destination table HISTORICAL. Change the code if you want.
Run the appendHistory routine and see what happens.

6) Post back here and we'll get you through it.
(the alternative to the code method I use here is to cut and paste the data,
or build and run append queries. Either can get tedious if you have lots of
tables.)

May 12 '06 #2

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

Similar topics

2
1949
by: David | last post by:
My organization currently has 2 different MySQL database servers. We are in the process of moving the databases from Server A to Server B and have Server B be our primary database server. I've done some research on the web and believe the best option is to use the "mysqldump" command to remotely recreate Server A's databases on to Server B. Can anyone please advise whether this is the best option? Also, using the "mysqldump" command,...
44
3868
by: Mariusz Jedrzejewski | last post by:
Hi, I'll be very grateful if somebody can explain me why my Opera 7.23 (runing under linux) doesn't show me inner tables. Using below code I can see only "inner table 1". There is no problem with other browsers (I checked it under Konqueror). Thank you in advance for your help. Regards. /Mariusz <HTML>
6
1528
by: imani_technology_spam | last post by:
Let's say I have two tables: CREATE TABLE dbo.OldTable ( OldID int NOT NULL, OldNote varchar(100) NULL ) ON GO
3
24018
by: Random Person | last post by:
Does anyone know how to use VBA to relink tables between two MS Access databases? We have two databases, one with VBA code and the other with data tables. The tables are referenced by linked tables in the database where the code resides. If we move the database with the data tables to a new directory, the links are no longer valid. I tried to update the links by changing the Connect property and refreshing: Set td = db.TableDefs(0)...
11
4514
by: dskillingstad | last post by:
I've been struggling with this problem for some time and have tried multiple solutions with no luck. Let me start with, I'm a novice at Access and I'm not looking for someones help to design my database,just help in getting me pointed in the right direction. I have a database with 8 tables, which from what I have read, cannot be linked on a single form, and be updatable. I have created a query which includes all 8 tables, and then...
2
1899
by: Gregc. | last post by:
G'day I have two tables with transactional data. Table 1 has a Cost Centre, Account, Fund Code and a YTD0-6 figure for each Account Number. Table 2 has Cost Centre, Account, Fund Code, Period 7, Period 8, Period 9, Period 10, Period 11, Period 12 data. Both Tables are linked to 'Data Tables' , Account Information, Cost Centres Information and Fund Type Information.
59
3641
by: phil-news-nospam | last post by:
In followups by Brian O'Connor (ironcorona) to other posts, he repeats the idea that using tables in CSS is not something that should be done because IE doesn't support it. Of course I'm not happy about the fact that IE doesn't support CSS tables. But what can one do about that? And tables of one type or the other are needed in some cases (regardless of whether some people feel it is appropriate or not). So the issue I and considering...
0
1161
by: xiaowei | last post by:
hi, I am using Access 2003. I have many tables which track the changes made to the data base. Each table caters to one previously existing table. Hope my explanation is clear enough. Each table have the same fields as previously existing table with addition of username (who makes the change) and date (when the change is made). Basically the old data and new data are both appended to the new tables.I want to consolidate all the tables into one...
2
1112
by: yasmine | last post by:
Hi friends, How can i consolidate the values of a table which occurs mostly? what i'm asking is consider a database which contains many tables. Each table has a field namely contents. The value of it may be repeated or not within a single table. what i need is how can i consolidate some of the values of contents field which occurs commonly in all or more tables? Please help me out... Thanx n regards yas
0
8139
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, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
8579
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed. This is as boiled down as I can make it. Here is my compilation command: g++-12 -std=c++20 -Wnarrowing bit_field.cpp Here is the code in...
0
8555
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
8232
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
8408
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
1
6064
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 presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
4032
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
1
2540
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
1
1686
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.