InfoPath 2007 - managed code, access database objects

I've recently begun working with InfoPath 2007 so my experience is limited.

I have a form built that uses one data connection to one table in a SQL database.  I've enabled Submit features on this form.  I also have all fields from the table being retreived by the data connection.

The situation is that I only want the user to enter necessary fields and not have to enter values for fields that are required by the database design, but really just store default values.

I'm planning on using VB.Net to code additional data submission logic into my Submit event handler.

I'd like if it's possible to add code that will update the values for these additional fields I don't want to force the user to enter these fields.  I thought about adding these fields to the form, making not visible, and applying default values, but would rather do in code if possible.


Who is Participating?
Clay FoxConnect With a Mentor Director of Business IntegrationCommented:
I don't do any more code in InfoPath than I have to, but I am sure there are samples to set values at

You would use Xdocument functions to access fields and values.

MSDN has a whole development document for InfoPath as well.
Clay FoxDirector of Business IntegrationCommented:
Well you do not have to make them visible to put defaults to them.

Either via code or via rule actions you can set the default of each field.  Some fields from data connections will not allow defaults directly but then you could also put a rule action on load or some other triggered event which set each field to what you want.

This is a common issue where there are housekeeping fields which are not relevant to the UI or the user but are required for a successful record submit.
JMO9966Author Commented:

If you have a code sample that does this type of work, that would be great.  I'd like to use code to explore more about the coding potential with InfoPath forms.
JMO9966Author Commented:
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.