Need code help for custom query to access DB PLEASE

M

myost

I've done some searching around and have seen a number of suggested
options but can't quite seem to get my code to work. My thanks to
S.Y.M. Wong-a-ton for getting me this far.

First, I've created an access 2003 database and then created an
infopath 2003 form using the access database as the primary data
source. I'm trying to use the database to pass data between forms.
One of the fields in the database is a boolean variable that I'm using
to flag the record I want to pull into the next form.

My goal is to create a button that will find any records that have the
flag already set as true and change it to false. This is just a check
to make sure the flag is cleared before setting it again. Thus far
I've got rough code created to query the access database using a
SELECT....FROM...WHERE statement.

My initial database connection is as follows:
select [ID],[firstName],[lastName],[supervisorEmail],
[praxaResponseOpen],[praxaResponseSent],[windowsResponseOpen],
[windowsResponseSent],[phoneResponseOpen],[phoneResponseSent] from
[New User Request] as [New_User_Request]

The connection name in infopath's data connections is:
"New_User_Request_DB"

My code behind the button thus far is:
function modQuery::OnClick(eventObj)
{
// Retrieve the field in the InfoPath form whose value will be used
in the
//WHERE clause
var node = XDocument.DOM.selectSingleNode("//my:trueText");
//my:trueText is a text field with default of "True"

// Retrieve the SQL statement of the data source
var strSQL =
XDocument.DataObjects["New_User_Request_DB"].QueryAdapter.Command;

// Generate the new SQL statement with WHERE clause
strSQL += " where [praxaResponseOpen] = '" + node.text + "'";

// Populate the command with the new SQL statement
XDocument.DataObjects["New_User_Request_DB"].QueryAdapter.Command =
strSQL;

// Run the query
XDocument.DataObjects["New_User_Request_DB"].Query();
}

The error I get when the button is clicked is:
'XDocument.DataObjects.New_User_Request_DB.QueryAdapter' is null or
not an object

If someone could help me with the inital query I'm pretty sure I can
take it from there. I've had some experience with vb and javascript
but I don't know enough to be able to debug this one. Any help would
be greatly appreciated. Thanks!

Michael
 

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