Home |
Search |
Today's Posts |
#1
![]()
Posted to microsoft.public.word.mailmerge.fields
|
|||
|
|||
![]()
I am doing a mail merge project that counts the number of instances of a
client in a table. When it trys to count the number of instances for a client that is not present in the table then it does not produce the required document. I guess this is because the sql command is throwing an error and the document cannot handle it so it just skips the relevant invoice. Is there any sort of try/catch statement that can be used within word? Thanks S |
#2
![]()
Posted to microsoft.public.word.mailmerge.fields
|
|||
|
|||
![]()
Is there a reason why you cannot write the SQL so that it always succeeds
(i.e. eliminates the clients with no invoices, or whatever it is that causes the problem? Maybe you could provide the SQL and say exactly in what circumstances the SQL fails? Although you can control the course of the Merge to an extent using Word's MailMerge Events - and in this case, the MailMergeBeforeRecordMerge Event is likely to be the one you need, but since Word itself is still fetching the records, I don't think you will be able to trap errors in there or do a try/catch that will catch this problem (probably worth a try though!) -- Peter Jamieson http://tips.pjmsn.me.uk "projectmergeleader" wrote in message ... I am doing a mail merge project that counts the number of instances of a client in a table. When it trys to count the number of instances for a client that is not present in the table then it does not produce the required document. I guess this is because the sql command is throwing an error and the document cannot handle it so it just skips the relevant invoice. Is there any sort of try/catch statement that can be used within word? Thanks S |
#3
![]()
Posted to microsoft.public.word.mailmerge.fields
|
|||
|
|||
![]()
The table is formatted as such
Client; number; description and the sql is counting the number of instances where client is equal to Client but if there is no Client in the table it does not create the invoice although the sql just returns 0. S "Peter Jamieson" wrote: Is there a reason why you cannot write the SQL so that it always succeeds (i.e. eliminates the clients with no invoices, or whatever it is that causes the problem? Maybe you could provide the SQL and say exactly in what circumstances the SQL fails? Although you can control the course of the Merge to an extent using Word's MailMerge Events - and in this case, the MailMergeBeforeRecordMerge Event is likely to be the one you need, but since Word itself is still fetching the records, I don't think you will be able to trap errors in there or do a try/catch that will catch this problem (probably worth a try though!) -- Peter Jamieson http://tips.pjmsn.me.uk "projectmergeleader" wrote in message ... I am doing a mail merge project that counts the number of instances of a client in a table. When it trys to count the number of instances for a client that is not present in the table then it does not produce the required document. I guess this is because the sql command is throwing an error and the document cannot handle it so it just skips the relevant invoice. Is there any sort of try/catch statement that can be used within word? Thanks S |
#4
![]()
Posted to microsoft.public.word.mailmerge.fields
|
|||
|
|||
![]()
Looking at it again. When the query executes if there are no entries in the
table where the count statement is being executed. It does not even add it to the table of results. But if there is one or more entry present it displays the line as normal with the count at 1. Thanks, S "projectmergeleader" wrote: The table is formatted as such Client; number; description and the sql is counting the number of instances where client is equal to Client but if there is no Client in the table it does not create the invoice although the sql just returns 0. S "Peter Jamieson" wrote: Is there a reason why you cannot write the SQL so that it always succeeds (i.e. eliminates the clients with no invoices, or whatever it is that causes the problem? Maybe you could provide the SQL and say exactly in what circumstances the SQL fails? Although you can control the course of the Merge to an extent using Word's MailMerge Events - and in this case, the MailMergeBeforeRecordMerge Event is likely to be the one you need, but since Word itself is still fetching the records, I don't think you will be able to trap errors in there or do a try/catch that will catch this problem (probably worth a try though!) -- Peter Jamieson http://tips.pjmsn.me.uk "projectmergeleader" wrote in message ... I am doing a mail merge project that counts the number of instances of a client in a table. When it trys to count the number of instances for a client that is not present in the table then it does not produce the required document. I guess this is because the sql command is throwing an error and the document cannot handle it so it just skips the relevant invoice. Is there any sort of try/catch statement that can be used within word? Thanks S |
#5
![]()
Posted to microsoft.public.word.mailmerge.fields
|
|||
|
|||
![]()
I'm sorry, you're going to have to spell it out for me as I don't really
understand what you are doing. Remember, we can't look over your shoulder! Are you by any chance doing a 1-many merge where the Mail Merge Data Source is "Client" and you are using a DATABASE field to insert a variable number of records that are related to that client? Or what? Is the SQL you are talking about the SQL to fetch the data source data or being executed in some other way. -- Peter Jamieson http://tips.pjmsn.me.uk "projectmergeleader" wrote in message news ![]() Looking at it again. When the query executes if there are no entries in the table where the count statement is being executed. It does not even add it to the table of results. But if there is one or more entry present it displays the line as normal with the count at 1. Thanks, S "projectmergeleader" wrote: The table is formatted as such Client; number; description and the sql is counting the number of instances where client is equal to Client but if there is no Client in the table it does not create the invoice although the sql just returns 0. S "Peter Jamieson" wrote: Is there a reason why you cannot write the SQL so that it always succeeds (i.e. eliminates the clients with no invoices, or whatever it is that causes the problem? Maybe you could provide the SQL and say exactly in what circumstances the SQL fails? Although you can control the course of the Merge to an extent using Word's MailMerge Events - and in this case, the MailMergeBeforeRecordMerge Event is likely to be the one you need, but since Word itself is still fetching the records, I don't think you will be able to trap errors in there or do a try/catch that will catch this problem (probably worth a try though!) -- Peter Jamieson http://tips.pjmsn.me.uk "projectmergeleader" wrote in message ... I am doing a mail merge project that counts the number of instances of a client in a table. When it trys to count the number of instances for a client that is not present in the table then it does not produce the required document. I guess this is because the sql command is throwing an error and the document cannot handle it so it just skips the relevant invoice. Is there any sort of try/catch statement that can be used within word? Thanks S |
#6
![]()
Posted to microsoft.public.word.mailmerge.fields
|
|||
|
|||
![]()
Its a join issue.
SELECT [Address Table].address, Count(text_message_table.Message) AS CountOfMessage, [Product Table].product_description, [Product Table].price, [Address Table].pay_sms, Min(text_message_table.ReminderDue) AS MinOfReminderDue, Max(text_message_table.ReminderDue) AS MaxOfReminderDue FROM text_message_table INNER JOIN ([Address Table] INNER JOIN [Product Table] ON [Address Table].client_id = [Product Table].client_id) ON text_message_table.Client = [Address Table].client_id WHERE (((text_message_table.ReminderDue) Between [Enter start date in the format DD/MM/YYYY] And [Enter end date in the format DD/MM/YYYY])) GROUP BY [Address Table].address, [Product Table].product_description, [Product Table].price, [Address Table].pay_sms; This is the sql but when I change the inner join to an outer join it complains about ambigious joins. It is the text_message_table to address table that is causing the problem as it will not join if there are no text messages and therefore does not return a row in the result table. Any help is very appreciated. Thanks, S "Peter Jamieson" wrote: I'm sorry, you're going to have to spell it out for me as I don't really understand what you are doing. Remember, we can't look over your shoulder! Are you by any chance doing a 1-many merge where the Mail Merge Data Source is "Client" and you are using a DATABASE field to insert a variable number of records that are related to that client? Or what? Is the SQL you are talking about the SQL to fetch the data source data or being executed in some other way. -- Peter Jamieson http://tips.pjmsn.me.uk "projectmergeleader" wrote in message news ![]() Looking at it again. When the query executes if there are no entries in the table where the count statement is being executed. It does not even add it to the table of results. But if there is one or more entry present it displays the line as normal with the count at 1. Thanks, S "projectmergeleader" wrote: The table is formatted as such Client; number; description and the sql is counting the number of instances where client is equal to Client but if there is no Client in the table it does not create the invoice although the sql just returns 0. S "Peter Jamieson" wrote: Is there a reason why you cannot write the SQL so that it always succeeds (i.e. eliminates the clients with no invoices, or whatever it is that causes the problem? Maybe you could provide the SQL and say exactly in what circumstances the SQL fails? Although you can control the course of the Merge to an extent using Word's MailMerge Events - and in this case, the MailMergeBeforeRecordMerge Event is likely to be the one you need, but since Word itself is still fetching the records, I don't think you will be able to trap errors in there or do a try/catch that will catch this problem (probably worth a try though!) -- Peter Jamieson http://tips.pjmsn.me.uk "projectmergeleader" wrote in message ... I am doing a mail merge project that counts the number of instances of a client in a table. When it trys to count the number of instances for a client that is not present in the table then it does not produce the required document. I guess this is because the sql command is throwing an error and the document cannot handle it so it just skips the relevant invoice. Is there any sort of try/catch statement that can be used within word? Thanks S |
#7
![]()
Posted to microsoft.public.word.mailmerge.fields
|
|||
|
|||
![]()
I'll try to pick this up later or tomorrow, but which dialect of SQL is
this? It looks like Jet/Access, but I'd like to be sure it's not something like Transact-SQL. -- Peter Jamieson http://tips.pjmsn.me.uk "projectmergeleader" wrote in message ... Its a join issue. SELECT [Address Table].address, Count(text_message_table.Message) AS CountOfMessage, [Product Table].product_description, [Product Table].price, [Address Table].pay_sms, Min(text_message_table.ReminderDue) AS MinOfReminderDue, Max(text_message_table.ReminderDue) AS MaxOfReminderDue FROM text_message_table INNER JOIN ([Address Table] INNER JOIN [Product Table] ON [Address Table].client_id = [Product Table].client_id) ON text_message_table.Client = [Address Table].client_id WHERE (((text_message_table.ReminderDue) Between [Enter start date in the format DD/MM/YYYY] And [Enter end date in the format DD/MM/YYYY])) GROUP BY [Address Table].address, [Product Table].product_description, [Product Table].price, [Address Table].pay_sms; This is the sql but when I change the inner join to an outer join it complains about ambigious joins. It is the text_message_table to address table that is causing the problem as it will not join if there are no text messages and therefore does not return a row in the result table. Any help is very appreciated. Thanks, S "Peter Jamieson" wrote: I'm sorry, you're going to have to spell it out for me as I don't really understand what you are doing. Remember, we can't look over your shoulder! Are you by any chance doing a 1-many merge where the Mail Merge Data Source is "Client" and you are using a DATABASE field to insert a variable number of records that are related to that client? Or what? Is the SQL you are talking about the SQL to fetch the data source data or being executed in some other way. -- Peter Jamieson http://tips.pjmsn.me.uk "projectmergeleader" wrote in message news ![]() Looking at it again. When the query executes if there are no entries in the table where the count statement is being executed. It does not even add it to the table of results. But if there is one or more entry present it displays the line as normal with the count at 1. Thanks, S "projectmergeleader" wrote: The table is formatted as such Client; number; description and the sql is counting the number of instances where client is equal to Client but if there is no Client in the table it does not create the invoice although the sql just returns 0. S "Peter Jamieson" wrote: Is there a reason why you cannot write the SQL so that it always succeeds (i.e. eliminates the clients with no invoices, or whatever it is that causes the problem? Maybe you could provide the SQL and say exactly in what circumstances the SQL fails? Although you can control the course of the Merge to an extent using Word's MailMerge Events - and in this case, the MailMergeBeforeRecordMerge Event is likely to be the one you need, but since Word itself is still fetching the records, I don't think you will be able to trap errors in there or do a try/catch that will catch this problem (probably worth a try though!) -- Peter Jamieson http://tips.pjmsn.me.uk "projectmergeleader" wrote in message ... I am doing a mail merge project that counts the number of instances of a client in a table. When it trys to count the number of instances for a client that is not present in the table then it does not produce the required document. I guess this is because the sql command is throwing an error and the document cannot handle it so it just skips the relevant invoice. Is there any sort of try/catch statement that can be used within word? Thanks S |
#8
![]()
Posted to microsoft.public.word.mailmerge.fields
|
|||
|
|||
![]() Its the default language in microsoft access so im gusessing it is Jet/access. Thanks, Steve "Peter Jamieson" wrote: I'll try to pick this up later or tomorrow, but which dialect of SQL is this? It looks like Jet/Access, but I'd like to be sure it's not something like Transact-SQL. -- Peter Jamieson http://tips.pjmsn.me.uk |
#9
![]()
Posted to microsoft.public.word.mailmerge.fields
|
|||
|
|||
![]()
SELECT [Address Table].address, Count(text_message_table.Message) AS
CountOfMessage, [Product Table].product_description, [Product Table].price, [Address Table].pay_sms, [Address Table].company_name FROM [Product Table] INNER JOIN ([Address Table] LEFT JOIN text_message_table ON [Address Table].client_id = text_message_table.Client) ON [Product Table].client_id = [Address Table].client_id WHERE (((text_message_table.ReminderDue) Between [Enter start date in the format DD/MM/YYYY] And [Enter end date in the format DD/MM/YYYY])) GROUP BY [Address Table].address, [Product Table].product_description, [Product Table].price, [Address Table].pay_sms, [Address Table].company_name; The join isnt actually the problem. I now have an outer join set up. The problem is that the final table only contains entries for each address if there exists a entry in the text_message_table between the date that are entered. I need it to return all of the entries in the address table but only count the number of messages between the dates. So I think the problem is in the where clause. Thanks, S "projectmergeleader" wrote: Its the default language in microsoft access so im gusessing it is Jet/access. Thanks, Steve "Peter Jamieson" wrote: I'll try to pick this up later or tomorrow, but which dialect of SQL is this? It looks like Jet/Access, but I'd like to be sure it's not something like Transact-SQL. -- Peter Jamieson http://tips.pjmsn.me.uk |
#10
![]()
Posted to microsoft.public.word.mailmerge.fields
|
|||
|
|||
![]()
I've got it sorted. I just needed to create a seperate query and then join
the two. Thanks, S "projectmergeleader" wrote: SELECT [Address Table].address, Count(text_message_table.Message) AS CountOfMessage, [Product Table].product_description, [Product Table].price, [Address Table].pay_sms, [Address Table].company_name FROM [Product Table] INNER JOIN ([Address Table] LEFT JOIN text_message_table ON [Address Table].client_id = text_message_table.Client) ON [Product Table].client_id = [Address Table].client_id WHERE (((text_message_table.ReminderDue) Between [Enter start date in the format DD/MM/YYYY] And [Enter end date in the format DD/MM/YYYY])) GROUP BY [Address Table].address, [Product Table].product_description, [Product Table].price, [Address Table].pay_sms, [Address Table].company_name; The join isnt actually the problem. I now have an outer join set up. The problem is that the final table only contains entries for each address if there exists a entry in the text_message_table between the date that are entered. I need it to return all of the entries in the address table but only count the number of messages between the dates. So I think the problem is in the where clause. Thanks, S "projectmergeleader" wrote: Its the default language in microsoft access so im gusessing it is Jet/access. Thanks, Steve "Peter Jamieson" wrote: I'll try to pick this up later or tomorrow, but which dialect of SQL is this? It looks like Jet/Access, but I'd like to be sure it's not something like Transact-SQL. -- Peter Jamieson http://tips.pjmsn.me.uk |
#11
![]()
Posted to microsoft.public.word.mailmerge.fields
|
|||
|
|||
![]()
Glad you got it sorted as I only just managed to get back to it...
-- Peter Jamieson http://tips.pjmsn.me.uk "projectmergeleader" wrote in message ... I've got it sorted. I just needed to create a seperate query and then join the two. Thanks, S "projectmergeleader" wrote: SELECT [Address Table].address, Count(text_message_table.Message) AS CountOfMessage, [Product Table].product_description, [Product Table].price, [Address Table].pay_sms, [Address Table].company_name FROM [Product Table] INNER JOIN ([Address Table] LEFT JOIN text_message_table ON [Address Table].client_id = text_message_table.Client) ON [Product Table].client_id = [Address Table].client_id WHERE (((text_message_table.ReminderDue) Between [Enter start date in the format DD/MM/YYYY] And [Enter end date in the format DD/MM/YYYY])) GROUP BY [Address Table].address, [Product Table].product_description, [Product Table].price, [Address Table].pay_sms, [Address Table].company_name; The join isnt actually the problem. I now have an outer join set up. The problem is that the final table only contains entries for each address if there exists a entry in the text_message_table between the date that are entered. I need it to return all of the entries in the address table but only count the number of messages between the dates. So I think the problem is in the where clause. Thanks, S "projectmergeleader" wrote: Its the default language in microsoft access so im gusessing it is Jet/access. Thanks, Steve "Peter Jamieson" wrote: I'll try to pick this up later or tomorrow, but which dialect of SQL is this? It looks like Jet/Access, but I'd like to be sure it's not something like Transact-SQL. -- Peter Jamieson http://tips.pjmsn.me.uk |
Reply |
Thread Tools | |
Display Modes | |
|
|
![]() |
||||
Thread | Forum | |||
Errors in Merge Document | Mailmerge | |||
What causes field calculation errors in mail merge? | Mailmerge | |||
Mail Merge errors | Mailmerge | |||
How to identify and correct mail merge 'field calculation errors' | Mailmerge | |||
Merge errors | Mailmerge |