R
ridawg
Hey,
With the code below I'm basically trying to do exactly what the New Record
action button does with addition of one line of code to switch to an
appropriate entry view. But I'm getting an Object Required error and I don't
know how to fix it. I found this code in another post so I don't really
understand how it works totally. The code is in VBScript. My intent is to
switch from the form's default view to a new entry view when a user selects
the New Filing button. The form has an Access database as it's datasource.
The line I'm having problems with is marked with a bunch of question marks.
Thanks!
Sub btnNewFiling_OnClick(eventObj)
'Create a new record and switch to New Filing entry view
Dim domTemplate
set domTemplate = CreateObject("MSXML2.DOMDocument.5.0")
domTemplate.async = False
domTemplate.load "template.xml"
If domTemplate Is Nothing Then
XDocument.UI.Alert "Could not load the template!"
Else
Dim existingDataFields
set existingDataFields =
XDocument.DOM.selectSingleNode("/dfs:myFields/dfs:dataFields")
domTemplate.setProperty "SelectionNamespaces",
"xmlns:dfs=""http://schemas.microsoft.com/office/infopath/2003/dataFormSolution"""
Dim newDataFields
set newDataFields =
domTemplate.selectSingleNode("/dfs:myFields/dfs:dataFields")
existingDataFields.parentNode.replaceChild
newDataFields.cloneNode(true), existingDataFields (????? This is the line the
error refers to)
XDocument.View.SwitchView("New Filing")
End If
Set domTemplate = Nothing
Set existingDataFields = Nothing
Set newDataFields = Nothing
End Sub
With the code below I'm basically trying to do exactly what the New Record
action button does with addition of one line of code to switch to an
appropriate entry view. But I'm getting an Object Required error and I don't
know how to fix it. I found this code in another post so I don't really
understand how it works totally. The code is in VBScript. My intent is to
switch from the form's default view to a new entry view when a user selects
the New Filing button. The form has an Access database as it's datasource.
The line I'm having problems with is marked with a bunch of question marks.
Thanks!
Sub btnNewFiling_OnClick(eventObj)
'Create a new record and switch to New Filing entry view
Dim domTemplate
set domTemplate = CreateObject("MSXML2.DOMDocument.5.0")
domTemplate.async = False
domTemplate.load "template.xml"
If domTemplate Is Nothing Then
XDocument.UI.Alert "Could not load the template!"
Else
Dim existingDataFields
set existingDataFields =
XDocument.DOM.selectSingleNode("/dfs:myFields/dfs:dataFields")
domTemplate.setProperty "SelectionNamespaces",
"xmlns:dfs=""http://schemas.microsoft.com/office/infopath/2003/dataFormSolution"""
Dim newDataFields
set newDataFields =
domTemplate.selectSingleNode("/dfs:myFields/dfs:dataFields")
existingDataFields.parentNode.replaceChild
newDataFields.cloneNode(true), existingDataFields (????? This is the line the
error refers to)
XDocument.View.SwitchView("New Filing")
End If
Set domTemplate = Nothing
Set existingDataFields = Nothing
Set newDataFields = Nothing
End Sub