A simple Select Case statement should do it.
I asked about what kind of checkbox because there are TWO checkboxes you can insert. One using the Forms toolbar (which is a formfield...and what you have done); the other using the Controls toolbar. These are ActiveX checkboxes, and are quite different than formfields.
I state a simple Select Case should do it, and it can. However, I am wondering WHY you are doing this? What exactly is the point? A user can check/uncheck the checkbox..any of them.
What exactly are you trying to accomplish?
So basically, what I want is a way to check one, but only one of 3 checkboxes depending on the text value in a forth field.
Hmmmm. These are different things. Calling it a "fourth" field is a misnomer. Formfields are actual things in a document. A custom property is not, really, a field. It can be put in a field, but it is, well, a document property.
A straightforward Select Case statement would be easy to write...but I have to ask you to think it through. Only because I don't know what you are really doing with your document.
Say you have Class2 in your custom property.
Code:
Sub YaddaYaddaBlah()
Select Case ActiveDocument.CustomDocumentProperties("Class")
Case "Class1"
ActiveDocument.FormFields("Check1").CheckBox.Value = True
Case "Class2"
ActiveDocument.FormFields("Check2").CheckBox.Value = True
Case "Class3"
ActiveDocument.FormFields("Check3").CheckBox.Value = True
End Select
End Sub
OK, that is straightforward. If Class = "Class2", the Class2 formfield gets checked.
But - and again I don't know what is really happening - it would NOT
uncheck the others, if they were checked. AND, there is absolutely nothing to stop the user from checking all the other, OR unchecking the Class2 checkbox.
So say the Class property was Class1 before, you change it to Class2, and run the code. Sure it will check Class2...but it will not uncheck Class1. Can you do that? Of course. Easy. What I am asking is what EXACTLY is the logic and purpose behind this?
As this could be (and probably is) a VBA question, you should likely re-post this into the VBA forum. However, to answer your question:
Now, is there a way that word can read the value of the text-property and check the correct checkbox based on the content of that field?
Yes, there is a way. There ya go.
faq219-2884
Gerry
My paintings and sculpture