Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

COMBINING TWO TABLES INTO ONE 1

Status
Not open for further replies.

rstitzel

MIS
Apr 24, 2002
286
US
I have two tables tbl_employeemaster_A10 and tbl_employeemaster_A20. I want to take these two tables and combine them into one table called tbl_EmployeeMaster. I have a function that clears the contents of the tbl_employeemaster and have been using append queries to update the table BUT I want to perform this action through a module. How do I go about writing this procedure.

Thanks in advance for any help.
 
Assuming your three tables have exactly the same table structure, this function should do the trick:

Code:
Function fctnMergeMe()
'Clear out main table first
CurrentDb.Execute ("DELETE * FROM tbl_employeemaster;")
'Then do some insertion
CurrentDb.Execute ("INSERT INTO tbl_employeemaster SELECT * FROM tbl_employeemaster_A10;")
CurrentDb.Execute ("INSERT INTO tbl_employeemaster SELECT * FROM tbl_employeemaster_A20;")
End Function

[pc2]
 
An alternative way of combining the tables would be to use a Union query.

Below is an example of SQL statement that combines four queries.

Select * from qxtbMoR_ThreatLevel
UNION ALL select * from qxtbMoR_VulnLevel
UNION ALL select * from qxtbMoR_Impacts
UNION ALL select * from qxtbMoR_MoR
ORDER BY Threat_no, Asset;

Each table/query must have exactly the same structure.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top