VBA - Combining 2 text datasource files - TechRepublic
General discussion
March 20, 2004 at 04:35 PM
cnwoods

VBA – Combining 2 text datasource files

by cnwoods . Updated 21 years, 8 months ago

I have 2 textual comma delimited files I need to query regularly, with some overlap in data and almost identical fields (different names on 2 of them). These are for orders filled locally and for orders filled for locals (filled anywhere).

So far I’ve been doing it with 2 access queries – a straightforward one for the first then a non-matched query for the second, but I don’t know how to combine both these queries into a single report (grouped by the filter criteria and including both datasources under each heading). It ends up in a word report, so I’m wondering if I’d be better off biting the bullet and creating a vba routine to import the two files, except there are two things I need to know first:
1. How do I get an import or merge to access data from two text files, and
2. I don’t know how I’d de-dupe the result (there will sometimes be legitimate duplicate entries where a single client has received multiple orders, so if a duplicate from the second file has already been removed, the next entry should be allowed).

Am I better off creating a query combining the two tables, generating a report and setting word up to pull it in using VBA; Doing it in Word in the first place via a VBA modification of the merge direct from the text files; or a combination using access to combine the two files and word to automatically filter/group it into the weekly templates I use. This already accesses an excel spreadsheet to pull in other stats, in case that impacts.

Although I’m pretty comfortable writing VBA routines in xcel, I’m relatively new to VBA in Access & Word. Answers assuming low-level knowledge would be appreciated.

Thanks, Crystal

This discussion is locked

All Comments