how do I query multiple different items at one time

K

KuramaFCPL

Hello, this may be stupid, but I am using a very basic one table access
database, and I am wanting to use infopath to pull just certian items by
their ID number and put them all on a form to print out. If someone could
please show me a way of doing this, I would be very grateful. Thank you.
 
K

KuramaFCPL

Drop down list would not be practicle for this database of about 2000
records. Plus Im not sure that was excactly what I was talking about. See
what I want to do is select records, 1354, 1643, 42, 1934, as an exsample,
and just bring up those records in a repeating table. Hope this helps you
understand my problem better. Thank you for taking your time to help.
 
S

S.Y.M. Wong-A-Ton

You didn't mention the 2000 records in your first post... And how does a user
know 2000 record IDs by heart to type them into a form to perform a search?

In any case, what you could do is bind your form to the database table and
then add the ID field from the queryFields section of the Main data source to
the InfoPath form. However, you won't be able to search by more than 1 ID
using this method, since InfoPath only offers exact searches if you use
InfoPath's interface to set up your querying.

A second more flexible option would be to add a text field to the form where
the user can type in more than 1 ID in a comma-separated format like
"1354,1643,42,1934". Then when s/he clicks on a button, you run custom code
to parse the contents of this text field, extract the IDs that were entered,
concatenate them to form a WHERE-clause using OR statements like e.g. "WHERE
ID = 1354 OR ID = 1643 OR ID = 42 OR ID = 1943", and then append this
WHERE-clause to the Command property on the DataObject of the Main data
source. You should be able to find many code samples online on how to do the
latter.

Hope this helps.
 
K

KuramaFCPL

ok, Thank you, not 100% on it yet, but I have a better understanding of it.
Im just lost on the code part. Im not a code person at all. would it just
be a VB script that I would plug into the button? and how would I go about
finding this script? or do I have to learn VB to write it. Thanks again.
 
S

S.Y.M. Wong-A-Ton

Yes, you could use either JScript or VBScript to write the code and put it in
the event handler for the button that runs the query. There are many samples
in this newsgroup on how to modify the Command property of a DataObject. Just
search on "DataObject", "Command", and "Query()" in this newsgroup. And yes,
it would help to know either JScript or VBScript when writing the code.

In the next few weeks I will focus a bit more on writing solutions that make
use of databases. I will convert your scenario into a solution and post it on
my website. So keep an eye out for it.
 
K

KuramaFCPL

Thanks a ton. You are my hero.

S.Y.M. Wong-A-Ton said:
Yes, you could use either JScript or VBScript to write the code and put it in
the event handler for the button that runs the query. There are many samples
in this newsgroup on how to modify the Command property of a DataObject. Just
search on "DataObject", "Command", and "Query()" in this newsgroup. And yes,
it would help to know either JScript or VBScript when writing the code.

In the next few weeks I will focus a bit more on writing solutions that make
use of databases. I will convert your scenario into a solution and post it on
my website. So keep an eye out for it.
 
Z

zeon

Hi was searching for something else and came across your post. There are at
least two simple wasy to do this without code:
1. Select tools, data connection, and modify the existing data connection.
click on the edit sql button. Add a where clause at the end of the statement,
such as
where "Diag_Code" between '0.15' and '002'
Then press the test sql button, before saving your changes.

2. If the data base allows a view to be built (MS/SQL does), create a view
that has the appropriate where clause, and then modify your data connection
to go against the view, instead of directly against the table.

Either way, no codding involved.
 

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