Gasman
Enthusiastic Amateur
- Local time
- Today, 19:30
- Joined
- Sep 21, 2011
- Messages
- 16,602
Hi all,
I have a query which is meant to produce data for letter mailmerge. the code is below.The query appends the record to a table to be used by Albert Kallal's word merge code.
It works as long as I have a joint flag set. the joint flag allows me to fill in extra fields in the client table, but the client might well be single or just want the cover for themself.
How can I get it to work in both scenarios please.?
TIA
I have a query which is meant to produce data for letter mailmerge. the code is below.The query appends the record to a table to be used by Albert Kallal's word merge code.
It works as long as I have a joint flag set. the joint flag allows me to fill in extra fields in the client table, but the client might well be single or just want the cover for themself.
How can I get it to work in both scenarios please.?
TIA
Code:
PARAMETERS LetterID Long;
INSERT INTO tblLetters ( ID, ForeName, MiddleNames, Surname, Address1, Address2, Address3, Address4, Address5, PostCode, DearNames, CSumAssured, CoverTerm, BenefitAge, CPremium, tAddFeatures, CDisposable, SupportPeriod, IllnessPeriod, cLoanAmount, LoanTerm, cLumpSum, LumpSumPeriod, OldCover, OldProvider, Event, SurvivePeriod, pRPIIncrease, pRPIMax, CoverNames, tJointSurvive, ProviderName, CoverType )
SELECT tblClientProduct.ID, tblClient.ForeName, tblClient.MiddleNames, tblClient.Surname, tblClient.Address1, tblClient.Address2, tblClient.Address3, tblClient.Address4, tblClient.Address5, tblClient.PostCode, IIf([JointCover],Trim([tblLookup].[LookupValue]) & " " & Trim([Surname]) & " & " & Trim([tblLookup_1].[LookupValue]) & " " & Trim([JointSurname]),Trim([tblLookup].[LookupValue]) & " " & Trim([Surname])) AS DearNames, Format([SumAssured],"£#,###") AS CSumAssured, tblClientProduct.CoverTerm, tblClientProduct.BenefitAge, Format([Premium],"Currency") AS CPremium, IIf(Len([AddFeatures])>0,[AddFeatures],"N/A") AS tAddFeatures, Format([Disposable],"Currency") AS CDisposable, tblClientProduct.SupportPeriod, tblClientProduct.IllnessPeriod, Format([LoanAmount],"£#,###") AS cLoanAmount, tblClientProduct.LoanTerm, Format([LumpSum],"£#,###") AS cLumpSum, tblClientProduct.LumpSumPeriod, tblClientProduct.OldCover, tblClientProduct.OldProvider, tblClientProduct.Event, tblClientProduct.SurvivePeriod, Format([RPIIncrease],"Percent") AS pRPIIncrease, Format([RPIMax],"Percent") AS pRPIMax, IIf([JointCover],Trim([tblLookup].[LookupValue]) & " " & Trim([KnownAs]) & " " & Trim([Surname]) & " & " & Trim([tblLookup_1].[LookupValue]) & " " & Trim([JointKnownAs]) & " " & Trim([JointSurname]),Trim([KnownAS]) & " " & Trim([Surname])) AS CoverNames, IIf([JointCover],"you both","you") AS tJointSurvive, tblProvider.ProviderName, tblProduct.ProductName AS CoverType
FROM tblProvider INNER JOIN (tblProduct INNER JOIN (((tblClient INNER JOIN tblLookup ON tblClient.Title = tblLookup.ID) INNER JOIN tblLookup AS tblLookup_1 ON tblClient.JointTitle = tblLookup_1.ID) INNER JOIN (tblClientProduct INNER JOIN tblProductProvider ON tblClientProduct.ProductProviderID = tblProductProvider.ID) ON tblClient.ClientID = tblClientProduct.ClientID) ON tblProduct.ID = tblProductProvider.ProductID) ON tblProvider.ID = tblProductProvider.ProviderID
WHERE (((tblClientProduct.ID)=[LetterID]));