Can I put a Rule on a Run Query Button?

M

Meg

I have a Run Query Button in InfoPath, but I can't find anywhere that I can
add a rule to it. Can it be done and if so, how?

Thanks,

MEG
 
Z

Zhang Haiguang

Please try to replace the Query Button with a common button, add the rule to
it, at last add a "Query using a data connection" action to the rule.

http://www.infojetsoft.com, InfoJet Service, a product likes InfoPath Forms
Services.
 
Z

Zhang Haiguang

Sorry, I don't know. Maybe you could clear the fields in "Set a field's
value" action one by one...
 
M

Meg

Thanks, I did try that but it still never gave me the results I wanted.
Maybe someone else out their knows.

It did clear the fields but, I have 2 views 1 is for data entry and 1 is for
search and edit. When I search for a record by name I get all the records
for that person which I want but when I want to complete a new record I
switch to the Data Entry View and it still has all the search records and I
want 1 blank form for them to enter another record.

Maybe I am asking too much.

MEG
 
Z

Zhang Haiguang

Please try to use codes to clear the query field and query result fields, as
the following InfoPath 2003 managed code:
[InfoPathEventHandler(EventType=InfoPathEventType.OnSwitchView)]
public void OnSwitchView(DocEvent e)
{
// Write your code here.
DOMNode idNode = thisXDocument.DOM.selectNodes(
"/dfs:myFields/dfs:queryFields/q:Employees/@EmployeeID" );
idNode.nodeValue = ""
if( thisXDocument.View.Name.Equals( "View 1" ) )
{
DOMNodeList nodeList = thisXDocument.DOM.selectNodes(
"/dfs:myFields/dfs:dataFields/d:Employees" );
foreach( DOMNode node in nodeList )
{
node.parentNode.removeChild(node);
}
}
}
InfoPath Web Form [http://www.infojetsoft.com]
 
Z

Zhang Haiguang

Oh, it should be:
[InfoPathEventHandler(EventType=InfoPathEventType.OnSwitchView)]
public void OnSwitchView(DocEvent e)
{
// Write your code here.
if( thisXDocument.View.Name.Equals( "View 1" ) )
{
DOMNode idNode = thisXDocument.DOM.selectNodes(
"/dfs:myFields/dfs:queryFields/q:Employees/@EmployeeID" );
idNode.nodeValue = ""
DOMNodeList nodeList = thisXDocument.DOM.selectNodes(
"/dfs:myFields/dfs:dataFields/d:Employees" );
foreach( DOMNode node in nodeList )
{
node.parentNode.removeChild(node);
}
}
}

Zhang Haiguang said:
Please try to use codes to clear the query field and query result fields,
as the following InfoPath 2003 managed code:
[InfoPathEventHandler(EventType=InfoPathEventType.OnSwitchView)]
public void OnSwitchView(DocEvent e)
{
// Write your code here.
DOMNode idNode = thisXDocument.DOM.selectNodes(
"/dfs:myFields/dfs:queryFields/q:Employees/@EmployeeID" );
idNode.nodeValue = ""
if( thisXDocument.View.Name.Equals( "View 1" ) )
{
DOMNodeList nodeList = thisXDocument.DOM.selectNodes(
"/dfs:myFields/dfs:dataFields/d:Employees" );
foreach( DOMNode node in nodeList )
{
node.parentNode.removeChild(node);
}
}
}
InfoPath Web Form [http://www.infojetsoft.com]

Meg said:
Thanks, I did try that but it still never gave me the results I wanted.
Maybe someone else out their knows.

It did clear the fields but, I have 2 views 1 is for data entry and 1 is
for
search and edit. When I search for a record by name I get all the
records
for that person which I want but when I want to complete a new record I
switch to the Data Entry View and it still has all the search records and
I
want 1 blank form for them to enter another record.

Maybe I am asking too much.

MEG
 
M

Meg

Thank you so much, I have not tried this yet (I am going to try today) but I
believe it is going to work.

I have 1 more question:

After I do the above, I am going to publish my form to another location. I
have already published it to our network drive here in my office. However, I
have mapped to another drive located in another State. I have put an
identical Database on their drive (all the tables are the same except
different employee names)

Can I publish my same form to their location so that when I update my form
here it will update theirs or do I have to save my form on their drive too
and then publish it from there?

A quick response would be greatly appreciated as they are waiting on my form.

Thanks,

MEG

Zhang Haiguang said:
Oh, it should be:
[InfoPathEventHandler(EventType=InfoPathEventType.OnSwitchView)]
public void OnSwitchView(DocEvent e)
{
// Write your code here.
if( thisXDocument.View.Name.Equals( "View 1" ) )
{
DOMNode idNode = thisXDocument.DOM.selectNodes(
"/dfs:myFields/dfs:queryFields/q:Employees/@EmployeeID" );
idNode.nodeValue = ""
DOMNodeList nodeList = thisXDocument.DOM.selectNodes(
"/dfs:myFields/dfs:dataFields/d:Employees" );
foreach( DOMNode node in nodeList )
{
node.parentNode.removeChild(node);
}
}
}

Zhang Haiguang said:
Please try to use codes to clear the query field and query result fields,
as the following InfoPath 2003 managed code:
[InfoPathEventHandler(EventType=InfoPathEventType.OnSwitchView)]
public void OnSwitchView(DocEvent e)
{
// Write your code here.
DOMNode idNode = thisXDocument.DOM.selectNodes(
"/dfs:myFields/dfs:queryFields/q:Employees/@EmployeeID" );
idNode.nodeValue = ""
if( thisXDocument.View.Name.Equals( "View 1" ) )
{
DOMNodeList nodeList = thisXDocument.DOM.selectNodes(
"/dfs:myFields/dfs:dataFields/d:Employees" );
foreach( DOMNode node in nodeList )
{
node.parentNode.removeChild(node);
}
}
}
InfoPath Web Form [http://www.infojetsoft.com]

Meg said:
Thanks, I did try that but it still never gave me the results I wanted.
Maybe someone else out their knows.

It did clear the fields but, I have 2 views 1 is for data entry and 1 is
for
search and edit. When I search for a record by name I get all the
records
for that person which I want but when I want to complete a new record I
switch to the Data Entry View and it still has all the search records and
I
want 1 blank form for them to enter another record.

Maybe I am asking too much.

MEG

:

Sorry, I don't know. Maybe you could clear the fields in "Set a field's
value" action one by one...

Is there a way to clear the form (make it blank) after running the
Query?

:

Please try to replace the Query Button with a common button, add the
rule
to
it, at last add a "Query using a data connection" action to the rule.

http://www.infojetsoft.com, InfoJet Service, a product likes InfoPath
Forms
Services.

I have a Run Query Button in InfoPath, but I can't find anywhere
that I
can
add a rule to it. Can it be done and if so, how?

Thanks,

MEG
 

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