I have set up a query so that I pull a single row back from a table (secondary data source), but I don't know how to assign the value to a variable.
Do I have to bind a form field to a column in the database table and then retrieve the value from the field? I have tried this approach but I am getting an "Object Required" error when trying to get the value from the form field (see function code below). Similar code works elsewhere in the form - maybe there is something wrong with the form field? It is a text box bound to the table in question.
I work for an organisation that has locked-down the PC so that no applications can be installed that are not part of the corporate strategy - hence I can't install any of the intermediate software to simplify things - I have to use infopath and access as they are.
The 'object required' error occurs on the red line below. I hope there is an obvious mistake that can be addressed.
Thanks in advance.
Function IsBankHoliday(uSicknessDate)
Dim uCalendarDataSource
Dim uHolidayDate
Dim uOriginalCommand
Dim uSingleRowCommand
' Modify the SQL command
uOriginalCommand = xDocument.DataAdapters("HolidayCalendar").Command
uSingleRowCommand = uOriginalCommand + " where [BankHolidayDate] = " + FormatDateTime(uSicknessDate, 2)
' Query the table with the the single row where clause and then reset the command
XDocument.DataAdapters("HolidayCalendar").Command = uSingleRowCommand
XDocument.DataAdapters("HolidayCalendar").Query()
XDocument.DataAdapters("HolidayCalendar").Command = uOriginalCommand
Set uCalendarDataSource = xDocument.DataObjects("HolidayCalendar").DOM
uCalendarDataSource.setProperty "SelectionNamespaces", "xmlns:xsi=""http://www.w3.org/2001/XMLSchema-instance"" xmlns:q=""http://schemas.microsoft.com/office/infopath/2003/ado/queryFields"" xmlns:d=""http://schemas.microsoft.com/office/infopath/2003/ado/dataFields"" xmlns:dfs=""http://schemas.microsoft.com/office/infopath/2003/dataFormSolution"" xmlns:my=""http://schemas.microsoft.com/office/infopath/2003/myXSD/2007-06-06T12:26:30"" xmlns:xd=""http://schemas.microsoft.com/office/infopath/2003"""
uHolidayDate = uCalendarDataSource.selectSingleNode("/dfs:myFields/dfs:dataFields/d:HolidayCalendar/@BankHolidayDate").text
If Len(uHolidayDate) > 0 Then
IsBankHoliday = True
Else
IsBankHoliday = False
End If
End Function