MS Word/Acess question

I have to design a Word document that is a mail merge using data from an Access query. Depending on some of the conditions, I need to have different text printed.

Now I know you can use If Then statements, but I am having a problem with them. Some of the fields in the query are a Yes/No field that are text (show Yes/no) but when you put the curser in the field they show either -1 (Yes) or 0 (No).

My problem is how to use the If statements with these Yes/No fields. Do I use If {mergefield} = Yes “print this” “or this” or do I use If {mergefield} = -1 “print this” “or this”?

I really havent had much of a problem with just one If statement, it is when nesting them that I run into the problem. If the conditions are met, it is’nt printing at all or printing the wrong thing.

Any help on this?

If needed, I can email you the document and the DB if necessary to help out with this mess.

If {mergefield} = -1 then
Print Yes
ElseIf {mergefield} = 0 then
Print no
End If

Happy to take a look if you want - addy from the contact us on here :wink:


Can’t send you an email. Get this message:

Sorry! That user has specified that they do not wish to receive emails. If you still wish to send an email to this user, please contact the administrator and they may be able to help.

So, if you could PM me with it please.

I have a question on the query Darin…

How many Yes/No Variables?

If it’s just one set the fast way to run is make two query’s then point the merge documents at each and print away… If it’s as simple as one document priint only where those fields = the query simply point at query. You can also make it faster on the build with usinig the MAKE TABLE from Query and point merge to that table…just a thought!

You can also ask me any time for help on VB/Access I think DT and I are the VB/Access/SQl and hmm general coding hackers…

Hope the info helps

Just thought I would let you know that I found the problem. Word and Access don’t play well together when it comes to a field being a simple Yes/No (-1/0) type. What I did was add a couple of fields to my query and then edit the document to reflect these field name changes. Here is an example of what the new field name bacame for the field Lack_DRC : txtLackDRC: IIf([Lack_DRC]=0,“N”,“Y”)

Now if the field Lack_DRC is a Yes(-1) condition it puts a “Y” in the field txtLackDRC. Word handles this much better than using the 0 or -1.

It was a very simple change to make along with the minimal editing of the Word document. It also didn’t require me to go digging through all of the code in Access to make changes.

Ok, finally tracked down exactly what was happening. As you know, within Access a Yes/No field actually returns a value of -1/0 depending on if the field is Yes (-1) or No (0).

Now it used to be that within Word, you had to use “-1” in the quotes for a -1 condition and “0” for the 0 condition. Then it changed that you didn’t include the quotes. M$ in their infinite wisdom has changed it yet again. This time, there is no documentaion (none that I could find). Now when the Access field is a Yes (-1) condition, you have to use True within Word. An example:

{If {Mergefield} = True “Print this if true” “This if condition is False”}