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.
I've added the following code to the save behaviour but I'm having trouble figuring out the syntax to pull data out of fields on the form.
This is my code:
Public Sub FormEvents_Save(ByVal sender As Object, ByVal e As SaveEventArgs)
Dim flname As String
flname = MainDataSource.CreateNavigator().SelectSingleNode("/myFields/dataFields/TimeTable/ID").ToString
Me.SetSaveAsDialogFilename(flname)
Me.SetSaveAsDialogLocation("g:\!workgrp\tenures\tenuretracking\savedforms")
e.PerformSaveOperation()
e.CancelableArgs.Cancel = False
End Sub
This is the error I get: (It works if I comment out the flname = statement.)
System.NullReferenceException Object reference not set to an instance of an object.
at Road_Permit_Amendment.FormCode.FormEvents_Save(Object sender, SaveEventArgs e)
at Microsoft.Office.InfoPath.Internal.FormEventsHost.OnSaveRequest(SaveEvent pEvent)
at Microsoft.Office.Interop.InfoPath.SemiTrust._XDocumentEventSink2_SinkHelper.OnSaveRequest(SaveEvent pEvent)
Can someone please tell me what I'm doing wrong?