Object Required Error - New Record Code

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
 
A

Adam Harding

Ridawg

Quickest way to return a blank form is to submit an impossible query to the
database it pulls back an empty form as no record satisfies the search.

I have set a date field to the year 3000 and it pulls back a blank form
every time. Similarly you could set up a series of actions from a rule to
acheive this.

Rule
Action 1 Set a fields value - Field1 - 1/1/3000 or 999999999 or ZZZZZZZZZZZ
Query using data connection - Main connection

Job done should pull back a blank form every time.

Cheers Adam
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top