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 bkrike on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Efficient Code

Status
Not open for further replies.

MrM121

Programmer
Aug 21, 2003
83
GB
Hi everyone, I was wondering if anyone could help me with making what I want to do more efficient. I need to be able to export 5 tables to 1 Excel workbook. The catch is that the tables are all linked on a one-to-one basis with a MainTable. All the tables have an ID field, which is the linking field. However, I need to be able to filter the MainTable by 3 fields, and then export all the tables with only the records that are in the MainTable. I hope I have made that clear, but if not, here is a query which I am going to have to reproduce for each of the subordinate tables:

SELECT tblReasonLeaving.ID, tblReasonLeaving.sngDismissal, tblReasonLeaving.sngEndOfCont, tblReasonLeaving.sngRedunComp
FROM tblMainData INNER JOIN tblReasonLeaving ON tblMainData.ID = tblReasonLeaving.ID
WHERE (((tblMainData.strOrgCode)="5H2") AND ((tblMainData.strMonth)=3) AND ((tblMainData.strYear)="03/04"));

I will then have to export this query to Excel, along with the other tables.

Is there an easier way of doing this kind of thing, preferably without the need for creating these queries, and I would like it to be as fast as possible.

Thanks,

Nick Meacoe
MrM@boltblue.com
 
Create a view, and then select from the view using the selection criteria
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top