Rule to Stop a Query if Invalid Search Criteria

M

mikeg

I want to prevent a query from running if a field is blank or contains an
invalid value. In the Run Query button properties, I created a Rule that
fires when the field value is blank or invalid. Then I added an Action to
send an error msg. This part is working fine.

However, after clicking OK on the msg dialog, InfoPath goes ahead and runs
the query anyway! I don't see any Action available to stop the query from
continuing other than "Open a new form to fill out" or "Close the form" which
are both overkill.

Note: I'm using the Rules and Custom Code Action in the query button for
some code that calls a stored procedure. It's working except that if the
search criteria is invalid my error msg will display, but then InfoPath
continues to run the query which I do not want.
 
B

brianmiller77

Mike,

Break your rule up into 2 different rules.

1st rule: check value for validity and if invalid show message box.
check the box at the bottom to stop processing rules.
2nd rule: set to condition to always run and query data

so if 1st rule runs because of an invalid field, 2nd rule won't run.
if field IS valid in 1st rule then rule will be skipped and 2nd rule
will run.

hope that helps.

Brian Miller
 
M

mikeg

Brian, thanks for the quick response. My form has four fields that can be
used for search criteria. I have four Rules defined. The first rule checks to
see if all four fields are blank and prints an error msg. "Stop processing
rules when this rule finishes" is already checked.

InfoPath correctly bypasses the other rules when the first rule fires, but
Infopath runs my custom query anyway. Adding another Rule at the bottom to
always run the query would be redundant in this case since it already runs
the query without such a rule.

I wonder if I need to add some logic to my custom Jscript query...
 

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