Microsoft Office Forums

Go Back   Microsoft Office Forums > >

Reply
 
Thread Tools Display Modes
  #1  
Old 12-19-2017, 10:41 AM
pdxplorer pdxplorer is offline Merged Checkbox Fields Always Checked Windows 10 Merged Checkbox Fields Always Checked Office 2016
Novice
Merged Checkbox Fields Always Checked
 
Join Date: Dec 2017
Posts: 6
pdxplorer is on a distinguished road
Default Merged Checkbox Fields Always Checked

Hi everyone,

We have a form that we use in a web application. The form gets merged through a C# library and then converted to PDF. On the form, we have checkboxes that follow this format:

Quote:
{ IF { MERGEFIELD Service_AS } = "" "[empty checkbox symbol]" "[checked box symbol]" } Air Sealing
If the C# service sends in a field called "Service_AS", the box should be checked. Otherwise, it should be blank. This has been working just fine for a while, but I recently had to add new fields to the form. I followed the same format, but these new fields - and only these new fields - are always checked on the resulting form, regardless of whether the field name was passed in.

I have debugged the code and it is not sending in anything wrong - it is definitely a problem with the Word doc. I've tried copy/pasting the working fields and just changing the code and label (which I now know won't work), I've tried manually adding or typing in the merge field code. I've double-checked that all the options are the same between a working field and a non-working field. I am completely bewildered -- everything looks the same, yet it is only the new fields that are working incorrectly.



Also, not sure if this is relevant, but I'm using Word 2016 and I'm pretty sure the doc was created in 2013 originally.

Any guidance would be super appreciated, or let me know if there any more information you need from me.

Thanks!
Reply With Quote
  #2  
Old 12-19-2017, 01:10 PM
macropod's Avatar
macropod macropod is offline Merged Checkbox Fields Always Checked Windows 7 64bit Merged Checkbox Fields Always Checked Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,956
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

Quote:
Originally Posted by pdxplorer View Post
If the C# service sends in a field called "Service_AS", the box should be checked. Otherwise, it should be blank.
You've done the field coding for MERGEFIELDS, but they can only get their content from the data source, not from your C# service. If your C# service is supplying anything, presumably it's doing that for a bookmark, document property or document variable, and you'd have to code the field accordingly.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #3  
Old 12-19-2017, 01:43 PM
pdxplorer pdxplorer is offline Merged Checkbox Fields Always Checked Windows 10 Merged Checkbox Fields Always Checked Office 2016
Novice
Merged Checkbox Fields Always Checked
 
Join Date: Dec 2017
Posts: 6
pdxplorer is on a distinguished road
Default Re: Merged Checkbox Fields Always Checked

Quote:
You've done the field coding for MERGEFIELDS, but they can only get their content from the data source, not from your C# service. If your C# service is supplying anything, presumably it's doing that for a bookmark, document property or document variable, and you'd have to code the field accordingly.
Hmm, thanks, but I don't think that's the issue. The C# library uses an XML data set in memory to load the fields. Also, the other fields all work correctly, whether checkboxes or text fields. It's only the new additions that stay checked.
Reply With Quote
  #4  
Old 12-19-2017, 01:50 PM
macropod's Avatar
macropod macropod is offline Merged Checkbox Fields Always Checked Windows 7 64bit Merged Checkbox Fields Always Checked Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,956
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

How did you create { MERGEFIELD Service_AS }?
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #5  
Old 12-19-2017, 01:57 PM
pdxplorer pdxplorer is offline Merged Checkbox Fields Always Checked Windows 10 Merged Checkbox Fields Always Checked Office 2016
Novice
Merged Checkbox Fields Always Checked
 
Join Date: Dec 2017
Posts: 6
pdxplorer is on a distinguished road
Default

I've tried two different methods:
- Copy/paste a working field and change the name (whether by typing or by choosing "Edit Field..." and changing there)
- Manually doing ctrl-f9 twice, adding the IF statement, and either typing the name of the merge field or doing the same "Edit Field..." and adding there.
Reply With Quote
  #6  
Old 12-19-2017, 02:00 PM
macropod's Avatar
macropod macropod is offline Merged Checkbox Fields Always Checked Windows 7 64bit Merged Checkbox Fields Always Checked Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,956
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

In that case, the problem is likely not to be with the field code. You might check what { MERGEFIELD Service_AS } returns on its own, just to make sure it's getting what you expect it to.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #7  
Old 12-19-2017, 02:15 PM
pdxplorer pdxplorer is offline Merged Checkbox Fields Always Checked Windows 10 Merged Checkbox Fields Always Checked Office 2016
Novice
Merged Checkbox Fields Always Checked
 
Join Date: Dec 2017
Posts: 6
pdxplorer is on a distinguished road
Default

Okay, thanks Paul. Do I do that with QUOTE? Also, is there somewhere I need to be setting a default value for these new fields? I notice that all of the old fields have empty checkboxes next to them when I open the form, but my new fields have empty space.
Reply With Quote
  #8  
Old 12-19-2017, 02:38 PM
macropod's Avatar
macropod macropod is offline Merged Checkbox Fields Always Checked Windows 7 64bit Merged Checkbox Fields Always Checked Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,956
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

No, you just insert the merge-field as-is somewhere in the document so you can see what output it's generating.
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #9  
Old 12-19-2017, 03:01 PM
pdxplorer pdxplorer is offline Merged Checkbox Fields Always Checked Windows 10 Merged Checkbox Fields Always Checked Office 2016
Novice
Merged Checkbox Fields Always Checked
 
Join Date: Dec 2017
Posts: 6
pdxplorer is on a distinguished road
Default

Okay, so, dumb question. It simply outputs:

Quote:
«Service_AS»
I did this by hitting Ctrl-F9 to insert brackets, right click, choose Edit Field, select MergeField and add the name.

I also just noticed that the Insert Merge Field button is grayed out in this document. I have no idea how or where this form was created, but maybe there is a problem with adding fields to this document. Is there a specific document type or property I need to check?

Sigh, thanks for all the help.
Reply With Quote
  #10  
Old 12-19-2017, 03:30 PM
macropod's Avatar
macropod macropod is offline Merged Checkbox Fields Always Checked Windows 7 64bit Merged Checkbox Fields Always Checked Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,956
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

The grayed-out Insert Merge Field button tells me this isn't a true mailmerge main document and the mergefields are just being used as placeholders (a fairly common misuse of mergefields).

As for the field merely outputting «Service_AS», that's to be expected for your document before your C# code runs. What do you see after it has run?
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
  #11  
Old 12-20-2017, 08:53 AM
pdxplorer pdxplorer is offline Merged Checkbox Fields Always Checked Windows 10 Merged Checkbox Fields Always Checked Office 2016
Novice
Merged Checkbox Fields Always Checked
 
Join Date: Dec 2017
Posts: 6
pdxplorer is on a distinguished road
Default

Quote:
The grayed-out Insert Merge Field button tells me this isn't a true mailmerge main document and the mergefields are just being used as placeholders (a fairly common misuse of mergefields).
Yes, that must be the case.

Quote:
As for the field merely outputting «Service_AS», that's to be expected for your document before your C# code runs. What do you see after it has run?
That «Service_AS» output is what shows up on the resulting PDF after the C# service is run, which is not sending a value for that field (In this test I am sending in a value for a different checkbox to test that the AS field is left unchecked). What I have is: "Service output: «Service_AS»" and I would expect to see "Service output: ". When other fields are blank they show nothing, they do not show their name or placeholder.

Is it crazy to think that perhaps this form was originally created as a proper Mail Merge doc and then somehow turned into a normal doc, and now adding fields isn't possible? I am really unsure what is causing this behavior.

Thanks.
Reply With Quote
  #12  
Old 12-20-2017, 12:37 PM
macropod's Avatar
macropod macropod is offline Merged Checkbox Fields Always Checked Windows 7 64bit Merged Checkbox Fields Always Checked Office 2010 32bit
Administrator
 
Join Date: Dec 2010
Location: Canberra, Australia
Posts: 21,956
macropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond reputemacropod has a reputation beyond repute
Default

If the «Service_AS» output is what shows up on the resulting PDF after the C# service is run, that indicates your C# service is not updating/replacing that field.
Quote:
Is it crazy to think that perhaps this form was originally created as a proper Mail Merge doc and then somehow turned into a normal doc, and now adding fields isn't possible?
A document doesn't need to be a mailmerge main document for someone to create mergefields in it. That can be done quite simply by pressing Ctrl-F9 to create the field braces (i.e. {}), then typing the relevant details between them (e.g. {MERGEFIELD MyField} which, when updated, displays as «MyField»).
__________________
Cheers,
Paul Edstein
[Fmr MS MVP - Word]
Reply With Quote
Reply

Thread Tools
Display Modes


Similar Threads
Thread Thread Starter Forum Replies Last Post
Merged Checkbox Fields Always Checked Odd Result In Combined Merged Time Fields JennEx Mail Merge 9 04-29-2017 08:58 AM
Total Checked FF Check Boxes CarlCR Word Tables 2 07-13-2016 12:01 PM
Merged Checkbox Fields Always Checked Adding sequential Number in a document that already has merged fields inserted Highlander01 Mail Merge 3 01-19-2016 12:33 PM
Checkboxes are unchecked in Listbox that were checked off before.How can I stop this? Rochelle711 Excel Programming 0 06-22-2014 06:16 PM
Merged Checkbox Fields Always Checked Repeat Spell check in a doc that has already been checked mawigfie Word 1 08-22-2012 01:16 PM

Other Forums: Access Forums

All times are GMT -7. The time now is 04:24 PM.


Powered by vBulletin® Version 3.8.11
Copyright ©2000 - 2024, vBulletin Solutions Inc.
Search Engine Optimisation provided by DragonByte SEO (Lite) - vBulletin Mods & Addons Copyright © 2024 DragonByte Technologies Ltd.
MSOfficeForums.com is not affiliated with Microsoft