Infopath 2007 Referencing to a Text Field - InfoPath Dev
in

InfoPath Dev

Infopath 2007 Referencing to a Text Field

Last post 11-25-2008 01:35 AM by amax2222. 2 replies.
Page 1 of 1 (3 items)
Sort Posts: Previous Next
  • 11-24-2008 08:15 PM

    Infopath 2007 Referencing to a Text Field

    Hi Please Help

     I have started with the Infopath 2007 travel request sample. I have added a button to my form. I have successfully added visual basic code to the button so that when it is clicked then an Outlook Meeting Request is created and sent. However I want to for example reference the starting date of the Outlook meeting request to the starting date on the travel form. But I don't see anywhere a reference in the VB window to my list of fields on my Infopath form. I tried the me. without success. Do I need to add a data source or import source or reference in my VB window?  My code is below. (I want to reference the agendaMeeting.Start = to an existing field on the Infopath form)

    Thanks for your help with this.

    Imports Microsoft.Office.InfoPath

    Imports Template3

    Imports System

    Imports System.Xml

    Imports System.Xml.XPath

    Imports Outlook = Microsoft.Office.Interop.Outlook

    Namespace Template3

    Public Class FormCode

    ' Member variables are not supported in browser-enabled forms.

    ' Instead, write and read these values from the FormState

    ' dictionary using code such as the following:

    '

    ' Private Property _memberVariable() As Object

    ' Get

    ' _memberVariable = FormState("_memberVariable")

    ' End Get

    ' Set

    ' FormState("_memberVariable") = value

    ' End Set

    ' End Property

    ' NOTE: The following procedure is required by Microsoft Office InfoPath.

    ' It can be modified using Microsoft Office InfoPath.

    Private Sub InternalStartup(ByVal sender As Object, ByVal e As EventArgs) Handles Me.Startup

    AddHandler DirectCast(EventManager.ControlEvents("CTRL60_5"), ButtonEvent).Clicked, AddressOf CTRL60_5_Clicked

    End Sub

    Public Sub CTRL60_5_Clicked(ByVal sender As Object, ByVal e As ClickedEventArgs)

    Dim OutlookApp As New Outlook.Application

    Dim agendaMeeting As Outlook.AppointmentItem = CType(OutlookApp.CreateItem(Outlook.OlItemType.olAppointmentItem), Outlook.AppointmentItem)

    If agendaMeeting IsNot Nothing Then

    agendaMeeting.MeetingStatus = Outlook.OlMeetingStatus.olMeeting

    agendaMeeting.Location = "Conference Room"

    agendaMeeting.Subject = "Leave Application"

    agendaMeeting.Body = me."Let's get together to discuss the Leave Application"

    agendaMeeting.Start = #11/23/2008 10:00:00 AM#

    agendaMeeting.End = #11/23/2008 11:00:00 AM#

    agendaMeeting.Duration = 60

    Dim recipient As Outlook.Recipient = agendaMeeting.Recipients.Add("James Wellington")

    recipient.Type = Outlook.OlMeetingRecipientType.olRequired

    agendaMeeting.Display()

    End If

    End Sub

    Protected Overrides Sub Finalize()

    MyBase.Finalize()

    End Sub

    End Class

    End Namespace

  • 11-24-2008 09:48 PM In reply to

    Re: Infopath 2007 Referencing to a Text Field

    Supposing you had a field in your form with the path my:myFields/my:startTime, where the user could fill in the meeting's starting time, the following would do the trick, as long as the value entered was valid:

     Dim startTimeNode As XPathNavigator
     startTimeNode = MainDataSource.CreateNavigator().SelectSingleNode(
    "my:myFields/my:startTime", NamespaceManager)
     
    agendaMeeting.Start = startTimeNode.ValueAsDateTime

    Jimmy Rishe / Software Developer / Microsoft MVP
    Qdabra Software
  • 11-25-2008 01:35 AM In reply to

    Re: Infopath 2007 Referencing to a Text Field

    Thanks Jimmy. I will give this a go.

    Do I need to do this everytime I reference to a field on infopath? Can I perhaps set a global parameter?

     

Page 1 of 1 (3 items)
Copyright © 2003-2019 Qdabra Software. All rights reserved.
View our Terms of Use.