Clearing text from "query fields"

A

abc

I have 2 questions if anyone can help. I'm connected to an access db
and using sp1. (jscript only)

1. I have about 6 query fields (dropdown lists).. when user selects
their criteria and clicks search.. it then populates into their
respective 6 data fields (textboxes). If they change their mind, and
select different criteria from a dropdown list, it does not populate
the criteria correctly. Is there a way to add a button that will clear
the query fields (drop down lists)?

2. I have 2 views on one form. The first view (from above) lets the
user search criteria. When the user finds the 'competency' they need
to update, they click on a button that switches views to the second
view and brings that criteria along w/ them to update. On this second
view, I have 2 dropdown lists and correlate with one another. For
example, one lists contains departments (Accounting, Finance, HR, etc)
and the other lists contains job titles (manager, supervisor,
associate, etc). Each dept have their own job titles, but some also
share the same name. When the user selects a dept name and then
selects a job title, the job title lists the names for that dept. My
problem is when I'm on the first view, it shares the same rules as the
second view. When I preview, one of the dept names is already
selected. Is there anyway to fix this?
 
V

virgul

Hi,

I don't really understand your second question (I'm french so It's
possible that I don't understand english as well as an english man)!

For your first question:

put a button in your form go on poperty and click Edit form code.

Infopath create you an event

Write the following code (Sorry I work with C# so it's in C# but you
can easily translate it):

thisXdocument.DOM.SelectSingleNode("yournode").text= ""; for each 6

If you have some differrent namespace prefix in this secondary data
source use :

IXMLDOMDocument2 oDomSearchHRG =
(IXMLDOMDocument2)thisXDocument.GetDOM("your secondary data source");
oDomSearchHRG.setProperty("SelectionNamespaces", "all your namespace");
oDomSearchHRG.selectSingleNode("/dfs:myFields/dfs:queryFields/tns:getAV/tns:nr(for
example)").text= "";

I hope this help!

++

Thierry
 
A

abc

Thank you for responding so quickly!

I'm not familiar with C# or jscript. All I know is that my form is set
to jscript (which cannot be changed). So I really don't know how to
translate this code =(

The second question: I'm just trying to figure out why a name in the
dropdown list is pre-selected when first viewing the form?
 
S

Scott L. Heim [MSFT]

Hi,

Actually you can do this with "Rules" - and if you simply want an easy way
to clear all the "query" fields of the previously selected choices, try
these steps:

-1) Open your InfoPath solution in Design View
2) Add a button to your form (near the query fields on your form)
3) Right-click on the button and choose Properties
4) Click the Rules button
5) Click Add
6) Click Add Action
7) From the Action box choose Set a field's value
8) Click the button next to Field
9) Expand "queryFields" and drill down so you can highlight one of the
query fields on your form and then click OK
10) Leave the Value field blank!
11) Click Add Action again and repeat steps 7-10 for each "query" field you
want to clear
12) When you have an action for all needed query fields, click OK until you
are back to your form
13) Preview and test the button - after making selections in your query
fields, you should be able to click the button and have all of them cleared
out!

I hope this helps...

Scott L. Heim
Microsoft Developer Support

This posting is provided "AS IS" with no warranties, and confers no rights.
 
A

abc

THANK YOU! It WORKS!

Can you answer my 2nd question? On my query fields.. department
dropdown list.. 'Accounting' is already pre-selected when I View my
form. Why is this? Does it have something to do w/ my rules on the
different view.. the correlation between the two dropdown lists
(Departments and Job Titles)?
 
S

Scott L. Heim [MSFT]

Hi,

Is that field populated when you first open the form or only after you have
switched views at least once? If it is populated when you first open the
form, then do you have any code or Rules that are executing open open?

Scott L. Heim
Microsoft Developer Support

This posting is provided "AS IS" with no warranties, and confers no rights.
 
A

abc

The field IS populated when I first open the form. What do you mean
open open? I have a rules on the other view for the data fields, but
it looks like it shares the same rules on this view even though its a
query field.

I used your directions for another user's post:
1) Create a new, blank InfoPath form
2) Add a drop-down list to the form named: ddlSuppliers
3) Add a drop-down list to the form named: ddlProducts
4) Add a new "Receive" data connection (Tools->Data Connections) to the

Northwind database using the Suppliers table. (Note: you will only need
the
SupplierID and CompanyName fields.)
5) Add a new "Receive" data connection (Tools->Data Connections) to the

Northwind database using the Products table. (Note: you will only need
the
ProductID, ProductName and SupplierID fields.)
6) Right-click on ddlSuppliers and choose Properties
7) On the Data tab select the option "Look up values in a data
connection
to a database..." under the section "List Box Entries"
8) Set the Data Connection to Suppliers
9) Click the button next to the Entries box, highlight "d:Suppliers"
and
click OK
10) Leave the Value field as: @SupplierID
11) Click the button next to Display name, highlight CompanyName and
click
OK
12) Click OK to close the Properties window
13) Right-click on ddlProducts and choose Properties
14) On the Data tab select the option "Look up values in a data
connection
to a database..." under the section "List Box Entries"
15) Set the Data Connection to Products


** NOTE: These next steps are important for the filtering! **


16) Click the button next to the Entries box, highlight "d:products"
and
click the Filter Data button
17) Click Add
18) In the first box, select SupplierID
19) In the second box, select "Is Equal To"
20) In the third box, choose Select a Field or Group
21) From the Data Source box choose Main
22) Highlight ddlSuppliers and click OK
23) Click OK three times to get back to the Properties window
24) Leave the Value field as: @ProductID
25) Click the button next to Display name, highlight ProductName and
click
OK
26) Click OK to get back to your form


** NOTE: These next steps are important for clearing out the previous
entries in ddlProducts once a new selection is made from ddlSuppliers!
**


27) Right-click on ddlSuppliers and choose Properties
28) Click the Rules button
29) Click Add
30) Click Add Action
31) From the Action box choose Set a field's value
32) Click the button next to Field, select ddlProducts and click OK
33) Leave the Value field blank
34) Click OK four times to get back to your form
35) Preview your form and make a selection from ddlSuppliers - you
should
only see a few items in the Products list.
36) Make a different selection from ddlSuppliers - you should now have
a
different list of Products!
 
S

Scott L. Heim [MSFT]

Hi,

Sorry...that was supposed to say the following:

"If it is populated when you first open the form, then do you have any code
or Rules that are executing on open?"

In other words, have you set any code or Rules that get executed when your
form opens? You mentioned that you do have Rules on some data fields - are
you sure the field that is in your query area is indeed a "query" field?
(Right-click on the field in your query area and choose "Show Data Source"
- this will confirm that the field is definitely from the query fields.)

When you followed the sample steps you did not see the same
behavior...correct?

Scott L. Heim
Microsoft Developer Support

This posting is provided "AS IS" with no warranties, and confers no rights.
 
A

abc

I double-checked.. my field is from queryfields. I even deleted the 2
dropdown lists from the second view and the rules.. still populating on
its own. I check my code.. (I haven't written any code). Any other
suggestions?
 
A

abc

I just noticed on my query field which is a dropdown list.. I deleted
it and rebound it.. manually entered the names (20 names) like i did
before... entered a couple of them.. previewed and its not populated...
enter more names and it now shows it pre-selected when I add the name
'RN', but when I take off 'RN' its not populated.. I can add many names
as long as I don't use the word 'RN'... any reason why its doing this?
 
S

Scott L. Heim [MSFT]

Hi,

When you Preview (or double-click) your form and click on the drop-down
lists do you have a blank row at the top of each one?

Scott L. Heim
Microsoft Developer Support

This posting is provided "AS IS" with no warranties, and confers no rights.
 
S

Scott L. Heim [MSFT]

Hmmm...not sure but I do have another question based on what you are doing.
It sounds as if your form is bound to a database or web services...is this
correct? If so, why are you adding entries manually? The query field
entries typically come from a database table...

Thanks,

Scott L. Heim
Microsoft Developer Support

This posting is provided "AS IS" with no warranties, and confers no rights.
 
A

abc

Well, I just bound the dropdown list to a secondary data source.. and
its still populating RN. =/
 
S

Scott L. Heim [MSFT]

Hi,

So it only "auto" populates the "RN"? Is this value set as a Default
anywhere? If not, I'm running out of ideas! <G>

Scott L. Heim
Microsoft Developer Support

This posting is provided "AS IS" with no warranties, and confers no rights.
 
A

abc

Morning!

Its weird.. I even bound the list to a totally different table and it
still auto populates 'RN'. I just started a new form and its not
auto-populating 'RN'. I can't figure out why it was doing that on my
original form... really strange!

... but.. Thank you for all your help!
 
S

Scott L. Heim [MSFT]

Hi,

Agreed but I am certainly glad you were able to get it working properly!

Take care,

Scott L. Heim
Microsoft Developer Support

This posting is provided "AS IS" with no warranties, and confers no rights.
 

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