<?xml version="1.0" encoding="UTF-8" ?>
<?xml-stylesheet type="text/xsl" href="https://www.infopathdev.com:443/utility/FeedStylesheets/rss.xsl" media="screen"?><rss version="2.0" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:wfw="http://wellformedweb.org/CommentAPI/"><channel><title>Code</title><link>https://www.infopathdev.com:443/forums/45.aspx</link><description /><dc:language>en</dc:language><generator>CommunityServer 2007 SP3 (Build: 31118.962)</generator><item><title>Re: Custom save function with code</title><link>https://www.infopathdev.com:443/forums/thread/52362.aspx</link><pubDate>Wed, 03 Mar 2010 00:33:04 GMT</pubDate><guid isPermaLink="false">033a2e2d-04e2-4a9d-be01-a4634161eefd:52362</guid><dc:creator>dc330</dc:creator><slash:comments>0</slash:comments><comments>https://www.infopathdev.com:443/forums/thread/52362.aspx</comments><wfw:commentRss>https://www.infopathdev.com:443/forums/commentrss.aspx?SectionID=45&amp;PostID=52362</wfw:commentRss><description>&lt;p&gt;Found the correct code for the flname = statement:&lt;br /&gt;&lt;br /&gt;&lt;font size="2"&gt;flname = MainDataSource.CreateNavigator().SelectSingleNode(&lt;/font&gt;&lt;font color="#800000" size="2"&gt;&lt;font color="#800000" size="2"&gt;&amp;quot;/dfs:myFields/dfs:dataFields/d:TimeTable/@ID&amp;quot;&lt;/font&gt;&lt;/font&gt;&lt;font size="2"&gt;, NamespaceManager).Value&lt;/font&gt;&lt;/p&gt;
&lt;p&gt;&lt;font size="2"&gt;Thanks to anyone who was looking at this for me.&lt;/font&gt;&lt;font size="2"&gt;&lt;/p&gt;&lt;/font&gt;</description></item><item><title>Custom save function with code</title><link>https://www.infopathdev.com:443/forums/thread/52358.aspx</link><pubDate>Tue, 02 Mar 2010 21:44:52 GMT</pubDate><guid isPermaLink="false">033a2e2d-04e2-4a9d-be01-a4634161eefd:52358</guid><dc:creator>dc330</dc:creator><slash:comments>0</slash:comments><comments>https://www.infopathdev.com:443/forums/thread/52358.aspx</comments><wfw:commentRss>https://www.infopathdev.com:443/forums/commentrss.aspx?SectionID=45&amp;PostID=52358</wfw:commentRss><description>&lt;p&gt;Hello, I want to add custom code (VB) to my Access database connected form which will generate a filename and path when the user clicks Save. &lt;br /&gt;I&amp;#39;ve added the following code to the save behaviour but I&amp;#39;m having trouble figuring out the syntax to pull data out of fields on the form. &lt;br /&gt;This is my code: &lt;br /&gt;&lt;br /&gt;Public Sub FormEvents_Save(ByVal sender As Object, ByVal e As SaveEventArgs)&lt;br /&gt;&amp;nbsp;&amp;nbsp; &amp;nbsp;Dim flname As String &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; flname = MainDataSource.CreateNavigator().SelectSingleNode(&amp;quot;/myFields/dataFields/TimeTable/ID&amp;quot;).ToString &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Me.SetSaveAsDialogFilename(flname) &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; Me.SetSaveAsDialogLocation(&amp;quot;g:\!workgrp\tenures\tenuretracking\savedforms&amp;quot;) &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; e.PerformSaveOperation() &lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp; e.CancelableArgs.Cancel = False &lt;br /&gt;End Sub &lt;br /&gt;&lt;br /&gt;This is the error I get: (It works if I comment out the flname = statement.)&lt;br /&gt;&lt;br /&gt;System.NullReferenceException Object reference not set to an instance of an object. &lt;br /&gt;&amp;nbsp;&amp;nbsp; at Road_Permit_Amendment.FormCode.FormEvents_Save(Object sender, SaveEventArgs e) &lt;br /&gt;&amp;nbsp;&amp;nbsp; at Microsoft.Office.InfoPath.Internal.FormEventsHost.OnSaveRequest(SaveEvent pEvent) &lt;br /&gt;&amp;nbsp;&amp;nbsp; at Microsoft.Office.Interop.InfoPath.SemiTrust._XDocumentEventSink2_SinkHelper.OnSaveRequest(SaveEvent pEvent)&amp;nbsp;&amp;nbsp;&lt;/p&gt;
&lt;p&gt;Can someone please tell me what I&amp;#39;m doing wrong? &lt;/p&gt;
&lt;p&gt;&amp;nbsp;&lt;/p&gt;</description></item></channel></rss>