The client has given us two excelworkbooks. and wanted us to match the policy numbers against them. So I exported the data in Access database (Two separate tables: one for TBLCancellationModes and another one for AnnutiesTBL) . Is there anything like VBA that I can use to find out the matching policy numbers ...
The problem, as you have stated it, is much like comparing apples and oranges.
You are using the PolicyNumber as if they were the same thing in the two tables. However, they are represented differently -- format/length.
Getting back to my apple and oranges analogy:
The only thing in common is that both are fruit.
You could say, they are both red, except for the orange. But that isn't helpful.
Comparing phone numbers with house numbers is a similar issue. Phone numbers, at least for us in North America, have a defined pattern. House numbers have no such universal pattern. You could compare the house number (24) in the address 24 Princess Street with all phone numbers. And seek those with the digits 24 contained within a phone number --but what does that really give you/tell you? You could even limit the 24 to the start of a phone number???
In my view, and I still don't think we have all the info, I would be attempting to find a common numbering scheme between/from the Annuities and Cancellation files. I'd investigate the background of these files.
I have worked to match company names, addresses, phones, contacts etc from a variety of files in different formats (and languages). Matching a pattern may be helpful, but usually requires additional properties to make a decision.