|
|
|||||||||
|
|||||||||
|
|||||||||
| |
|||
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Display Modes |
|
#1
|
|||
|
|||
|
Automating Mailmerge To Existing Documents
Hi Guys
I'm having real trouble with this and hopefully you can help. I have a requirement to set up an automated mailmerge to work from a make table query. This query sets up a table which contains only the data to be merged at any time and it is determined by a renewal month. However, and this is where I'm running into some problems, if the renewal is one year old, I want the merge to use 'doc1', if it's two years to use 'Doc2' if it's older than two years to use 'Doc3' and finally (phew!!!) if it's in the current year to be ignored. So, the three documents are already created in word and are in the same directory as the database and a basic mailmerge works but, when I try and use a if then loop, the code starts to go funny on me in that if there is more than one branch in th eloop it doesn't seem to recognise what I want it to do, when I try to compile the code it highlights the End Function part and says there is a block 'If' statement with no End If but there is and, of course if I replace the End Function statement it looks for that. I realise that it's more than possible that I can't do what is required but that would be okay as long as I know it can't be done..... Also, in the if then loop, I'm trying to set up the criteria as If Year([Date]) = Year(Now())-1 etc and whgen I do this it highlights the square brackets and gives a compile error something like, unable to recognize external call.... I know I'm doing something really badly wrong here but I'm not good enough with code to know what it is, can anybody help. Thansk in anticipation HarryM |
|
#2
|
|||
|
|||
|
HarryM,
The End If that is missing is in the procedure somewhere. The End Function is highlighted but the actual problem is somewhere in the code. Follow down each If statement carefully and you will probably find the missing End If. As far as your If statement with the date, a couple of things. First depending on where this part of the code is placed in your procedure, you may have to show the date as a variable rather than a call. Second, I would suggest renaming the field to something other than Date. Date is an Intrinsic Constant and access may not distinguish between the constant and your field name correctly. If you still run into problems, post your function and let us look at it. lwells |
![]() |
| Viewing: Dev Articles Community Forums > Databases > Microsoft Access Development > Automating Mailmerge To Existing Documents |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|